From patchwork Sat Oct 22 07:18:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7153 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1087944wrr; Sat, 22 Oct 2022 00:38:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ZfY4D/SP88k3N6gamwMLcNnQbSyZAx59fBD+wwOxZCAp4W1xAquQ0EnLHpFDgjRR0sq/R X-Received: by 2002:a05:6402:35cc:b0:45d:4a39:2a43 with SMTP id z12-20020a05640235cc00b0045d4a392a43mr21244846edc.304.1666424296687; Sat, 22 Oct 2022 00:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424296; cv=none; d=google.com; s=arc-20160816; b=pQ6v0fZ2JnGVRe6S6jH/miXp50v1ZVh7zcZ4PSStv+YyIVTmeDSHwP3Ai5Qu2EmRzl 8b7UYQ9RJsp8ssalPXYh0p7Q1FAW8SA8/iTPAItBCAV6IjJGLrwRd1S7LNMsVmZdaagD SJtGHmDObpAYUlQjKJo++XucFO9gDLg4vScSo2n2OWvk+oOnGHDWxBLnIX1CutipSLIF 5rjM3rurPzXvTy4BEPF2isme9YLiACFbkrDHS4FdXUefJJAhFBDXZ75Qg6+l61KtgKKO y5OdEcbnUK1vucSVlxz01JbsP9XEqZ8snWGVoRqhHwA1egIoFG54whaxzxzP7El1UBJc s/kg== 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=Xvr0T5p9BjZra5Tnje4HnWDZ6+YpjFB/eNc7nqOV021OWRlp1EokDBSJwIcDoJkMFi YJkB7eONzHtOdcEdsDquWOYTuo6QXY2GlTq9cnpxjSg6Li7gEg4AHgsKA9UGsSwCATEH NVxi0urh+iPjkBuWH1oCZMKxbFwyFVXQUk4qBtRbhWjSIwUXeQ0UfSX9bySmmiBLMmbQ QQVOHnX9JK6kRT+HlX3iPx8SIkv89zkKpGtDNtxjFWjwBC7MTYxEIweoVY2pkaDx2kT6 uPmgeQGj5Gl4G0jX38fiGwrivFgaJb+Ns06/8TyqF9JUKWjCOd2nw07OgvrzOdpgl0Uu Ujuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AnLs+eng; 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 r3-20020a50c003000000b0045d4f99616dsi1838357edb.456.2022.10.22.00.37.52; Sat, 22 Oct 2022 00:38:16 -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=AnLs+eng; 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 S230315AbiJVHhb (ORCPT + 99 others); Sat, 22 Oct 2022 03:37:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbiJVHgu (ORCPT ); Sat, 22 Oct 2022 03:36:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F15A81843FB; Sat, 22 Oct 2022 00:35:19 -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 69FDA60ADA; Sat, 22 Oct 2022 07:35:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E6CEC433C1; Sat, 22 Oct 2022 07:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424114; bh=nqOrFT/Y66TGULVPHHQkkVqwTkFRjIX6uhUPep+lG1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AnLs+engcI05TfhztNYFBozcy9Y2708HEE84WZ0yZyEuscgcyYOmNfezTPSY0g6w4 P2UwTXkE5odLoc5/kxcER2qEQyZOuqB8iyY4sz9JlgSE/LXSuZTP2Z02bcKGAm5Hme 61sK/0j49J1Idqod9xDOY81SLH4EctclHpIcPWCs= 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.19 005/717] ALSA: usb-audio: Fix NULL dererence at error path Date: Sat, 22 Oct 2022 09:18:04 +0200 Message-Id: <20221022072415.997711105@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747372523488809898?= X-GMAIL-MSGID: =?utf-8?q?1747372523488809898?= 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)