Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6747137rwi; Mon, 24 Oct 2022 05:43:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7lIqbs1+GJvxde2GeDcd+Y99i8MyrAJ6sZCnr73vPyUrkNnZm+oDORoINK8bdYzVLzqU27 X-Received: by 2002:a05:6402:a46:b0:461:ed76:cb56 with SMTP id bt6-20020a0564020a4600b00461ed76cb56mr1600841edb.264.1666615420570; Mon, 24 Oct 2022 05:43:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615420; cv=none; d=google.com; s=arc-20160816; b=V+ykmaEo2oXmqdnDJd6Yqmsn0+DZUYkjGq6usS9WyKpaF5SS/6Xzn1GCMzWIiqXl3V naEXlD05SfMwkoRwpXsNFuNMiJd4z1zYCNs8fknqiJJAWXoPQFrcJ98FoF5h8OwSmLLc AKM+6xuUL9F0eQ0J1YqJUhRBRRyA/+SzCkJV2jT+RKmaqUcrCrXUt45mG7iAGl84sk3c zT60JOLN/R3C2q8BqIbKy3Wo6Z/UKVmTyh5TNEywfV+TrNW/Ciz53lfOuQ2PLSlwRcDt 4jW3+bZEutbKRwZ8weygB8y5OyaNFZGFJXMGbNI0XRQbc7KlKeaMuSiDc+EDdxlQHiw2 AoqQ== 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 Return-Path: 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.43.05; Mon, 24 Oct 2022 05:43:40 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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)