From patchwork Mon Oct 24 11:26:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp545195wru; Mon, 24 Oct 2022 09:33:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ALWcaf6SEDLo7RmZjHpirL/FjDKPAFDYGUdKnUjM7NiFuDtWsZ4pWkjrPiYZ88pxN8AXH X-Received: by 2002:a17:907:7ea6:b0:791:81f4:b0e3 with SMTP id qb38-20020a1709077ea600b0079181f4b0e3mr28857969ejc.164.1666629233769; Mon, 24 Oct 2022 09:33:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666629233; cv=none; d=google.com; s=arc-20160816; b=J/cm5hHVBNYkOnWLvOS22cfmAUIX8MFvcODNrpmYo3+8txrJ5PmQ7aGRsTUclpxT1o 9ci6u4kHXn2lvPxcpnOcPHeewHCBfdd0LlmoUzSocWGxSnexi3V4al1+ZJ8/dC3zkVgo Wrn79qLlADODJ4KL6qDnRocXVsGfZWpyaeCDi7G35V8wMRuMo4r2kXw+Yf9ox2kC0YIi GfelyEXyNefeuIdT7ToOxTFZkVgfSgRXcTdrxF2eFxIjWyUw4j1wJ9YDpO0E7dJZyyOf MKa8tRqH8UUsbj2MfhUYIG1e3d/VVvMluOh7H/AMikEZMVyHnCZXoTOGVk70Rn0xDIZO 7L/g== 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=e4WF8MZKOWxNjYn+IQkC7LfUxfwFrA/TYSxCWE4Pb80=; b=IiOyRcs4pYUOHHURhf4TWHLxjBLCR+9EAJVWJt1I4JIveKOeAZQO1AW+aq5ceoDJfD wGX9IPA6mABOPcLWhOs/abXbhwGWJaVxf+aXJyi+wAGPbUxNSh2nOCDws0zsEd/ONIJE YpKWzpbaUAFYUZPHw2axcfR6JKltih6+rkJp8RiDDRm6RIWqlhgaxNku25iYeK6IDYWC xidITUfJ1vZU75hTavmW305O71+Hiy+E2r3Dy/U2CKMBDL5kF4GNnr8JxeuSFGMVRO+U 5a9byvUgJJ4srQrldisiAME+SPYOIQuhZuA19bUR5LglQGjX3gvRcJc9r8gYk+e+b6/0 otSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L0ZtmSr6; 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 dr13-20020a170907720d00b0078db6f488cesi297158ejc.112.2022.10.24.09.33.30; Mon, 24 Oct 2022 09:33:53 -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=L0ZtmSr6; 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 S231698AbiJXQT6 (ORCPT + 99 others); Mon, 24 Oct 2022 12:19:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232196AbiJXQRX (ORCPT ); Mon, 24 Oct 2022 12:17:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D6C0A98DE; Mon, 24 Oct 2022 08:04:14 -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 69352B81440; Mon, 24 Oct 2022 12:16:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6660C433B5; Mon, 24 Oct 2022 12:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613792; bh=QALW6qxGWjYOL34jei31N12I63Ao9E+i3afP07mCzJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L0ZtmSr6NWHTSCLEes4nMK/xxWxH+Bj8ZXbHT9g1h7HWLL/rXW6enNAzLoFHxZqqf ev0a0gkWugfaFE3n7dO0OpGzHbZEPh2ASshbo3rdecYYfwAwpPzBc3L9Wkv1zS0nRN Tw0aUl4ozsa6Cn5+0Lau3T4Cmbzo/6N76Y4M/IJ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 5.10 003/390] ALSA: usb-audio: Fix potential memory leaks Date: Mon, 24 Oct 2022 13:26:40 +0200 Message-Id: <20221024113022.677325981@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?1747587415753051892?= X-GMAIL-MSGID: =?utf-8?q?1747587415753051892?= From: Takashi Iwai commit 6382da0828995af87aa8b8bef28cc61aceb4aff3 upstream. When the driver hits -ENOMEM at allocating a URB or a buffer, it aborts and goes to the error path that releases the all previously allocated resources. However, when -ENOMEM hits at the middle of the sync EP URB allocation loop, the partially allocated URBs might be left without released, because ep->nurbs is still zero at that point. Fix it by setting ep->nurbs at first, so that the error handler loops over the full URB list. Cc: Link: https://lore.kernel.org/r/20220930100151.19461-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/endpoint.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -998,6 +998,7 @@ static int sync_ep_set_params(struct snd if (!ep->syncbuf) return -ENOMEM; + ep->nurbs = SYNC_URBS; for (i = 0; i < SYNC_URBS; i++) { struct snd_urb_ctx *u = &ep->urb[i]; u->index = i; @@ -1017,8 +1018,6 @@ static int sync_ep_set_params(struct snd u->urb->complete = snd_complete_urb; } - ep->nurbs = SYNC_URBS; - return 0; out_of_memory: