From patchwork Mon Oct 24 11:29:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8661 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp421747wru; Mon, 24 Oct 2022 05:21:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM50+nlVIfZmp9ZAyJei750R24YTwyNQ+SCif3fIxIAMEEu6PtU5J1zacT2yyM22OkCXxuRr X-Received: by 2002:a17:907:9707:b0:78d:45d1:487e with SMTP id jg7-20020a170907970700b0078d45d1487emr26898571ejc.566.1666614067843; Mon, 24 Oct 2022 05:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666614067; cv=none; d=google.com; s=arc-20160816; b=fNR4f+UUbd6htbzAqnY5NC4dPlurI2ZKGBjelqQdcWzySqUO4GHlCsjTJi9AosL580 KaJ+3bEQ7LNhO/ZI2vLWIXH9qiCm9uf3ocVRgA8HYRYM511rNAxUuENjDmZy6ItUNONQ JrSx5bvW44EWkHJeuwBe0fWKL7cEyDAoFgvc6VL1MkGz87xNtv013u8git53g8mt65kp LNybF9AzH+01diGK157ySj1tr0XicVm7nOGm6OE1bHQLKgxPaFpMbniMuaNJO7xilcqJ pz4TY1D6gqXdc2nRg+5RsiaXo2C+/vmjSuHFhVTmtZiA44xMdGjcdj6I38nb4hEMllCm tTrA== 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=LxefP1LFjtZYe7ylOZUO5MlxjhXvhUYnL3tn30Em73S5TcTd9OVmzyL9p1P9yraSI3 x3AYwrJQlXwrFKdr9mSuakre96nSpDz42s2L+yFZPoOgUelqHIHKaxKSzBfKc/L57nze LuNC90zfEDkAmO7WS9C/zBOFOlKb7g3NkzcqMowfNmeh8sZlgTG25ILxCUAs0eEnkMsb YL7hgcnkbzsNxGaIH8hyzCRnHKVyGqUvvAlEon6W0iThw3FHW3E08xrQKWmIzM/cK7vO 9pq1vAdFEi90OGJUWdI3feKT8gqnRPI7WYlCqmudn+vgeIZ3mMV2UnbnuY19eMs955PF MkUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HmbJg15G; 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 r11-20020a05640251cb00b0045d9ceae6d8si20641901edd.492.2022.10.24.05.20.43; Mon, 24 Oct 2022 05:21:07 -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=HmbJg15G; 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 S233178AbiJXMRJ (ORCPT + 99 others); Mon, 24 Oct 2022 08:17:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233442AbiJXMPH (ORCPT ); Mon, 24 Oct 2022 08:15:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91B6E773BF; Mon, 24 Oct 2022 04:56:04 -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 5544B612B9; Mon, 24 Oct 2022 11:56:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63D5DC433D6; Mon, 24 Oct 2022 11:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612563; bh=FSdbiPueVjPIiHHnV4K5YK5PYMbHBcrAoHkWO81VVtQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HmbJg15GqgeJFEPZJBCchrIDPK2tHZFFiHCXRSoQTLNQrTuqNWjnSGQcqhgtS4n7c y3AryHt1rtpgPVbSgE9uKPxYH9jfocf8g4ouQ1dyIFkN9+WqN47v2GgHVjZT0Ooo4R xzxlZFQoC9Xhqm+2CpgUOKRXWqJXGwv+72QBCnrY= 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.19 035/229] ALSA: usb-audio: Fix NULL dererence at error path Date: Mon, 24 Oct 2022 13:29:14 +0200 Message-Id: <20221024113000.246577547@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@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?1747571512730635301?= X-GMAIL-MSGID: =?utf-8?q?1747571512730635301?= 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)