From patchwork Wed Oct 19 08:21:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4505 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp202603wrs; Wed, 19 Oct 2022 01:41:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Nn1jcD1zTyZ2kn2aw+J9KYSxt1SViaCajdu0OY37+t2foDNRQJe/l+eb58D9e1NWVzUo0 X-Received: by 2002:a17:907:1b1f:b0:72f:56db:cce9 with SMTP id mp31-20020a1709071b1f00b0072f56dbcce9mr5507694ejc.605.1666168860233; Wed, 19 Oct 2022 01:41:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666168860; cv=none; d=google.com; s=arc-20160816; b=pg2H/WSuYAvsUVJmOWGQ5XnwJo2mJxjY0xIS8pG3Tws/CzykxaX4HMDk9uJHi781Kz FvVL7M6RY8OJ2bkS+/LMwWOEKZNkwxr7ni6uFvkVAceJ0Wtjm1uHoHDsnrjBWeizSvzs 5uwAmwsRAF8uRhhW8h6RNS8ozc2hKQ907y9H0ynfrIM1kc8F5CL+tEOjMAEp681ltO6l BRS0it00IJ9dpgDWOaxkZI12EJM8xXEi7mo4FrbsjzHotRNM9h69BX8pZb9DllvJAcp/ Ftz+dGukIDo9TTOGHh4vLR+b810HUBiqNIc/L2kqEibsh4cFq+RJ3TygTPPZO6SJGxLT s4AQ== 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=z80ZjE2YL/ZbpBogZGd3BFMn4gDm6TtkhkZ2yiRsiRA=; b=nZFZFC8jvQvn3F+lGVO536OkOv8KGXWOcdWEsmhNuayc+Znhxy1K4GdZGM9PBp2Mxq H8wLCBmH/HSKAfVpwTNm+/mDrI0YTkF0QrsJz3+TDQHM+9VTXenBDPilHGfOHcELYjDz wElBbeDkJAZjaKZFiT3xq1Oeur2Pwwx9rBxU7uZvaD2srcow9AtnMouU1T7gXbGfMUtp 87z8qWNV2wedKbGQ3YHdIKz2HvguHuAxwjIXsh3MZrI7FtSru4kH+S7FN/xLyN6AOO+r 46f+Ga46pJlbqfVMqMb93a0gmcVns5/IvSGjUGavqMGtWGs+RMdZgEwdtkkyyHn9tiBj wRQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="elwc1a/Q"; 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 30-20020a508e1e000000b00458b204f294si11855637edw.298.2022.10.19.01.40.35; Wed, 19 Oct 2022 01:41:00 -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="elwc1a/Q"; 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 S230270AbiJSIjy (ORCPT + 99 others); Wed, 19 Oct 2022 04:39:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229971AbiJSIjD (ORCPT ); Wed, 19 Oct 2022 04:39:03 -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 A62787F0B1; Wed, 19 Oct 2022 01:38:40 -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 D481E617DF; Wed, 19 Oct 2022 08:38:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0186C433D7; Wed, 19 Oct 2022 08:38:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168713; bh=nqOrFT/Y66TGULVPHHQkkVqwTkFRjIX6uhUPep+lG1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=elwc1a/Qav0Bmc5YpjsPcpseSSsUR6H7omx5rMuLpRarq1jvseELMvXyJNJjVWVz/ qkggq1G2jSWkzGWLmgmB4gq+x3g5p0moDNQOKFYt03HgwVx8eYY5T8G6kYI4O7RN8s Si0ei6z1E8ycp0o3R8W4iTXgazL3gnIzd9jRK+YM= 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 6.0 004/862] ALSA: usb-audio: Fix NULL dererence at error path Date: Wed, 19 Oct 2022 10:21:31 +0200 Message-Id: <20221019083250.187859993@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747104678798061383?= X-GMAIL-MSGID: =?utf-8?q?1747104678798061383?= 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 @@ -93,12 +93,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)