From patchwork Mon Oct 24 11:29:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8807 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp430947wru; Mon, 24 Oct 2022 05:42:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5FzH1A8YrAofaGKIaYuicIzLFK2zm6+xt/OwWYqPn+yYu9jfZl9J/q+j00PpHC+iKUAV6s X-Received: by 2002:a05:6402:348b:b0:45c:b22b:c4a9 with SMTP id v11-20020a056402348b00b0045cb22bc4a9mr31423744edc.65.1666615354786; Mon, 24 Oct 2022 05:42:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615354; cv=none; d=google.com; s=arc-20160816; b=GonWfh8pLfFyzwm+j14SDMgIsWmTL4pTKQLcF765/xl+osPP9uaomX4IZGhIZj5ocH hhNf3lI230/ChQFTyqp6J4JQANZmE+FPZbeGy1YhtYH5GjeGZS8IpC0JwmyxMJz662h8 1AKVvn/4N9kjrafEqD6EKw3ihGn8wqXoo4qH/VL9NJwCArm9rieSFARakhurMBO/rsrt KpA+jIetgUeI+Gw0t+bdJeOVJsMAxBTBr5usAYbFZPjnxw8aIvAbUtzFzE8sbDAc70gy U9nbTwUj8esPYSw9aEhEIADX7Q0PUiKSE6pix61I5PFekVVc4ZowyXPpeyF/c9zqDKR0 1+gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DdFZ1cinygSsriobG550QUqAq5pltVLrhdrXA4ROhCc=; b=vXl6uK3PpuiAP6LEG7k6PqN30fc9qSfABfhk+JmYG9Apedy3SH1lo4NGltl5d6cFFp zG9AjocCgzAF4541ARJXUGS7+oAMuTZtd6A9XbRT7XPj8SJlGAm0dVmQHENlMmSWhcvS BtbqEJNszh2yDXwLfFlpSNz5tB41XM1d1aFs+z8aDLMxgzJonqg/QSqCEXUVwfOR14mO n84BQ2Sv3z0lrHZCEKpbfyIuNBnc2arrjiV7zsZokPlFjGP0yMfdN+iCG5Tlwi92O91g v9eMPAld4SYZI9Mr8Q+QBcFqnZsf44kukFxHEBe6h4kEMw6+TqAbKYzVujsJQsDPpaCe xVxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YBudlojf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m15-20020a056402430f00b0043d54ba0a4dsi33530349edc.327.2022.10.24.05.42.10; Mon, 24 Oct 2022 05:42:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YBudlojf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234151AbiJXMeO (ORCPT + 99 others); Mon, 24 Oct 2022 08:34:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234165AbiJXM3b (ORCPT ); Mon, 24 Oct 2022 08:29:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2737588DD2; Mon, 24 Oct 2022 05:03:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 59D42612B4; Mon, 24 Oct 2022 11:47:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B60AC43143; Mon, 24 Oct 2022 11:47:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612056; bh=FSdbiPueVjPIiHHnV4K5YK5PYMbHBcrAoHkWO81VVtQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YBudlojfPoBf11VHpn0Nknvsr7rKigpT16OpFOoZF9Ig4UrKmGKQcorCDQO3RIqF5 uKlH6g/aczNVlekbHJ60ZfKJjZrPTj5q9dVsQZ8bBiiPH7cVpwYSMRe9+nxiVVbV08 abcBNTnlQRped95J+SsvMvLGVbcZ4NhRHP0a7qC0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Sabri N. Ferreiro" , Takashi Iwai Subject: [PATCH 4.14 053/210] ALSA: usb-audio: Fix NULL dererence at error path Date: Mon, 24 Oct 2022 13:29:30 +0200 Message-Id: <20221024112958.720040159@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747572862295821604?= X-GMAIL-MSGID: =?utf-8?q?1747572862295821604?= From: Takashi Iwai commit 568be8aaf8a535f79c4db76cabe17b035aa2584d upstream. At an error path to release URB buffers and contexts, the driver might hit a NULL dererence for u->urb pointer, when u->buffer_size has been already set but the actual URB allocation failed. Fix it by adding the NULL check of urb. Also, make sure that buffer_size is cleared after the error path or the close. Cc: Reported-by: Sabri N. Ferreiro Link: https://lore.kernel.org/r/CAKG+3NRjTey+fFfUEGwuxL-pi_=T4cUskYG9OzpzHytF+tzYng@mail.gmail.com Link: https://lore.kernel.org/r/20220930100129.19445-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/endpoint.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -86,12 +86,13 @@ static inline unsigned get_usb_high_spee */ static void release_urb_ctx(struct snd_urb_ctx *u) { - if (u->buffer_size) + if (u->urb && u->buffer_size) usb_free_coherent(u->ep->chip->dev, u->buffer_size, u->urb->transfer_buffer, u->urb->transfer_dma); usb_free_urb(u->urb); u->urb = NULL; + u->buffer_size = 0; } static const char *usb_error_string(int err)