From patchwork Mon Oct 24 11:29:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8420 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp400412wru; Mon, 24 Oct 2022 04:47:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5gbsyg29ozXa1uAuik52vRphS3DNraFF7bdAy9hcLeqokiOUJYfeERGnJzFF3Ygk94a/F2 X-Received: by 2002:a05:6402:5162:b0:457:6ef2:df3 with SMTP id d2-20020a056402516200b004576ef20df3mr30244082ede.128.1666612024799; Mon, 24 Oct 2022 04:47:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666612024; cv=none; d=google.com; s=arc-20160816; b=KkrZF2SBhy2QOslxlf/zFzkQH6b2dBrcsEwp12auA1Tp/OlI+Pxi6FKkejKsN3/qF1 Mn5bnP29+cnowj7fMT05ulUzctr6zIt+Tx4vox+8DyVpm0Yg3DrAd2AjH4pCPA9T30Qc AtmpurRLsEtc9+AGk/sBWObEEUfk0gbBTfHpGaDugWiSmzGLn6B9Hv7kygkx7IodM56V eGZH2zrIP6fRbsCH0OAoEmp6PAxTQl5dVVsQdS9Sp5nQ85VZ5GdNUVTfp3wWoyktmA/T Ia3t53h+2TAUW+BPBMGUWporP4n5mxkE86kfEdAAlkf43LSI4//fu2z9ZATrzn7UkRVT LSDg== 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=oBjJYdzEQsA507ZEJB0mrPemb8P31MftbE5astkoNpA14heAlSTrQE1b5+advxFAU7 TmMSnojFr5cn6xDK5wTimHNIGENAWRy3L30UpIuMZTeBUZ0bIVPVGqiKTdvD8Qx6vBkU HokfXMvRnEXQSlQbpqxuMvM59IZY1xM5fPLxb0lTUyxdAEIowZr0uvlsDHdUFKSrwCLd hvANkj+9255SQpJU6J9POCPIkylXTE9F4AHgHYUnwYvqQyvfdGnlKd+bG/Hjci2Bearz Ic3WSYDRLqjL9KdqNOiFl6VoQofeeFxqUNCFaTSlIqly8cggAC7cKp2bQxlD3+vZfkCW XAjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TkF8h0C6; 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 q24-20020a50c358000000b004610f91a242si10053962edb.300.2022.10.24.04.46.40; Mon, 24 Oct 2022 04:47:04 -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=TkF8h0C6; 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 S231577AbiJXLqL (ORCPT + 99 others); Mon, 24 Oct 2022 07:46:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231710AbiJXLoT (ORCPT ); Mon, 24 Oct 2022 07:44:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7973C748D7; Mon, 24 Oct 2022 04:41:43 -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 ams.source.kernel.org (Postfix) with ESMTPS id E14EDB81151; Mon, 24 Oct 2022 11:40:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E81DC433C1; Mon, 24 Oct 2022 11:40:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611612; bh=FSdbiPueVjPIiHHnV4K5YK5PYMbHBcrAoHkWO81VVtQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TkF8h0C61ggFfo6kLqMzzPERT+dnEZFuWMwEHj3TWAXBMQChqIuE2vIeV8bXCcinm 0wuiKF1YZOks04tRyaS7RBBzfdyVK3qNuzkp/ndsFVn9w4Wkqj6L3QEUJupgUHzdAg kf16ccLZQC6LeJMCNoX93EzXQAAKBmwHkvtj2UUM= 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.9 044/159] ALSA: usb-audio: Fix NULL dererence at error path Date: Mon, 24 Oct 2022 13:29:58 +0200 Message-Id: <20221024112950.999694278@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112949.358278806@linuxfoundation.org> References: <20221024112949.358278806@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?1747569370410285160?= X-GMAIL-MSGID: =?utf-8?q?1747569370410285160?= 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)