From patchwork Sat Oct 22 07:18:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7152 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1087920wrr; Sat, 22 Oct 2022 00:38:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7QYKzVqPRtKlw1o7vAu5fkouXqHQNjX7/4e2q7qpXyR0sHM7ZEs69v9y1PrxPTjpyPm4Tb X-Received: by 2002:a17:906:eec9:b0:783:e662:2513 with SMTP id wu9-20020a170906eec900b00783e6622513mr18758521ejb.656.1666424290529; Sat, 22 Oct 2022 00:38:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424290; cv=none; d=google.com; s=arc-20160816; b=CpVYfmPQDxYDPAk5v8hHRjIaxPPc7n1B710un9I/n/e3H+N0ObJ3EUaCHJBe9iq4Hc sc2j65gBcj2E+1PzAAiOkc4GrEKklJCqF8+GpnZ5B4HGuNDNvB+lqnGk8k4IoFhLmmsu OKFk4SumKlTDOwxXM8f1CNI3AWAUl9KgRquyfFj3Z3gFRV9ZNd0khsuf2hUje3pJoEi9 kkndTKTMj8M3Lb8PxHfNgnnFxKfNha7a8z4KxaymiRkq52080iKJNtDfwlrV3YN3hDDY IAIY6ZCzMmYjTD4ZfVhVeXWyUoCViU4es5WKwdMTiHR6HLbj973GRfG2NbPqrLsvh1N0 HMoQ== 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=+JWXyrfUpuPNSadoVrKpARPqPk4jtBbPH1fSNQ2syHo=; b=eTl2JyOnzXqkj28W0QHKjYUi9PXlSIQPZYhGyKSuKXmBpMJF0JtbyBLI7uJfjNoi2l 0nwyWEDywPnYKmAW4gnSeIuxRIYsEJgjsHi129lLGTNYwQkFguVu1OOcE1R8AD2GUsxX OeyjVyfMaBIQg4NiS+jtmtmxjyVtwC9CbSEJM2OM3v6C0mxXdXlwWwYlPTsubr2vOa9Q sZAD+7GNJplROiBwwSp3bmUevE9vbxgJHlPwdqJPTVy61tmJ9HaJqiTs21Y9lBJMD0b9 uRXEQli6qh2HBWqe901Tpr5QPMw+Q4RQtaukNg1u8Yttfh63QZzOAw7fSlUkt4vQAUwg Fmxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uGhlicha; 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 e5-20020a056402104500b00458bef9c70esi20133507edu.612.2022.10.22.00.37.46; Sat, 22 Oct 2022 00:38:10 -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=uGhlicha; 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 S230267AbiJVHhF (ORCPT + 99 others); Sat, 22 Oct 2022 03:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230270AbiJVHge (ORCPT ); Sat, 22 Oct 2022 03:36:34 -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 61E65357C5; Sat, 22 Oct 2022 00:35: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 dfw.source.kernel.org (Postfix) with ESMTPS id 3D37460AD9; Sat, 22 Oct 2022 07:35:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21DB8C433D6; Sat, 22 Oct 2022 07:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424111; bh=FAUBq+xOHHhAmdDXr0nUjCQSE5N3RTGbcKi+sVW2no4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uGhlicha5W5p6nz0UBLnh0bBklqIdqqsfQjUMzZ0KRL856CHq8ouFRMgQwsIplSvJ VAUI+mscD34GvME6npHwRvPJEq6Q/GkR1204j7fjmcy1A1fCM8Yq8A/f/CNLCbt6Rm 405pdp1Ugk8xDf3BbTVibsWKD1gdR2YG8PvKkh4Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 5.19 004/717] ALSA: usb-audio: Fix potential memory leaks Date: Sat, 22 Oct 2022 09:18:03 +0200 Message-Id: <20221022072415.820715261@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?1747372516885795306?= X-GMAIL-MSGID: =?utf-8?q?1747372516885795306?= 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 @@ -1261,6 +1261,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; @@ -1280,8 +1281,6 @@ static int sync_ep_set_params(struct snd u->urb->complete = snd_complete_urb; } - ep->nurbs = SYNC_URBS; - return 0; out_of_memory: