From patchwork Mon Oct 24 11:26:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8986 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp439245wru; Mon, 24 Oct 2022 06:02:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6UlnJZZn/3uEriqNhCQjNDjiW+PrZzdqwT27kuA6/VXLJZgUWvm9QVKUfS308ji8G8DDDD X-Received: by 2002:a63:2212:0:b0:43b:f03d:856a with SMTP id i18-20020a632212000000b0043bf03d856amr28195937pgi.192.1666616546834; Mon, 24 Oct 2022 06:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616546; cv=none; d=google.com; s=arc-20160816; b=W7FFRwsmyh9xuJXWImbGvSgZSO++aioOfiM16zKX8kzRsUMgOo4vz5zSpqZqiK3GGj kJaBVUeytyeDT52M72upgEUVgDZSKbZVsFdkdr05pJhM8UEbvk7zvYWybgElE37818fW Eo4ynUM0iexPXYLuUuvy0987Nxw0xaF0lwX6EtWjfqGPAvpTXISCpScD6ZsxyhIdmU4/ wRia1DLJndhtZMFouOulSxu2BmyD3eLGxs3og4EX8ZJWO6At5aock0F1boVvFjLDAa8W jDAYvGEK4LgjZ4MnLR8UWkG/FVRVUZm1GDLB2BoEUyNScteJasBD6f6rRvGU2xWncJRv ci2g== 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=vLR9Hr4pXaDXczSJ/XRKFG6VHjgezLfmfS/NgjnLuts=; b=jKt8lRa4GcdQtEx8vZEJw4m30LqVO/V6nGdM0scZeiw8VofJf7NMYEQwb7EmhHHYFn Wje6iyvv6Pq/362B14QMmM5EFTawvOWC+izzFUz5nS+UbW8QzLYKQJ2FkF4nkU/o7bNx EWDJrD0pYwkNAJ6kTd8C6EIoPbMPc5ao8ALTgRD+AW8u05/+wz2XqFt9GTJISWk3JRWx TprjALRgC3ivCRovVrSDrBDxSRnclgXnoVEl+/gsJTruOTuBvAFU5Wv9zFHRHfIkcU9S KmtfLuKLTgzpxFYXzKfw8d1da6soW8BjDZRikZ9lW0vuZWWQfUiDxCYIud1LYNCekGYv sDtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QBs+AQLe; 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 f20-20020a631f14000000b0046ae8195c0asi35799571pgf.611.2022.10.24.06.02.03; Mon, 24 Oct 2022 06:02:26 -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=QBs+AQLe; 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 S235091AbiJXNBX (ORCPT + 99 others); Mon, 24 Oct 2022 09:01:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235011AbiJXM7I (ORCPT ); Mon, 24 Oct 2022 08:59:08 -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 5515B9A9D0; Mon, 24 Oct 2022 05:18:18 -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 3476461336; Mon, 24 Oct 2022 12:16:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A850C433C1; Mon, 24 Oct 2022 12:16:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613794; bh=Lo+CknCpFzfV4+jmHuHa+7rRUKqZ5GoheRpToAyZR2Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QBs+AQLe2eSR3JQ7gUySDUeUqrhQb7LiKoeOBl1x/Uvh7PV6OmFuAw7eVkfaYbxam KS7ks/uk/AC+oKMgr2vRyZVX11PZmw115opUQYUvm3sdS35bLxQV0JOAIADaO9JZNW zUqPGADv+9neSWp+uhq1zGlXn0b0HhCa1PaslT9s= 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 5.10 004/390] ALSA: usb-audio: Fix NULL dererence at error path Date: Mon, 24 Oct 2022 13:26:41 +0200 Message-Id: <20221024113022.716441526@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@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?1747574112573763606?= X-GMAIL-MSGID: =?utf-8?q?1747574112573763606?= 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 @@ -73,12 +73,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)