From patchwork Wed Oct 19 08:21:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4515 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp203132wrs; Wed, 19 Oct 2022 01:42:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7EphdsX+olVskBYYd3TscpzdOxXi3MsidYwavIdf88iPJ6iqCGHTEY7G9MwMFKBODdBjVc X-Received: by 2002:a50:9991:0:b0:458:a612:bf5a with SMTP id m17-20020a509991000000b00458a612bf5amr6435439edb.22.1666168939818; Wed, 19 Oct 2022 01:42:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666168939; cv=none; d=google.com; s=arc-20160816; b=pHUTyAlt+zxim91V/y9fLIDS/Y5cxFxmf50gcx9nLLrV1pqBYpSglvryjHXXAgq4d8 cyhMMhUITNTxY9hvX2yIxjbYBjrmRBOU3xYobtbtu1Q3OWrSmE54kpZhbz5aXrpJQPrY FyDfAeAffVKduPkzZrUZ8R0wfzqIXCcDCz/jr1jQpBs0DPPFUarFbPfLrZjjYBtUN80W Khr5KxiVG9nLdBuqQgk0IInA0TAluQ8xpKqqNiFDaNeSvii+4W9R9SdCO6oq4npRnkXI xuCitrg0FXuWtJjhS8PO5ETSk6cY1MVU7Y17VClE+NTHmNV0fxCkvuyPe94LinZcBYiV /CvQ== 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=qFv8V2bpcPbWh4YJ/X/a09XhErkhSJrKUFNAkrMecDhSSPT64zUC65j4OPNpZf5ND7 AOrgqLYYew2bxOl928DBcA1n1mM1+p66W8SD/Pe+n6d69+xzZkeYsuX3Yp26jDKArT4n HRdsOFD/Q1D8ebCBuiEMHNw/J7XVtjhrTbrmWuvGTrnR+GSxtWw9WBlyVK7jU48AHkbC zwb4BpwR+6KNJ71aWHgnVgc0JOST9IFlk4I/lMbKBbVeVwcqOcnQw47yDqBHGhP4KjPh FrvaDPP/8mWe6PjY63LiKo/6S6m7c/ImzaU7lSthSaE5MVrBLjCIOb3zSIEYWg1bdSMo fdIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Sa31d34L; 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 hv17-20020a17090760d100b007807e3f6766si7664409ejc.581.2022.10.19.01.41.54; Wed, 19 Oct 2022 01:42:19 -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=Sa31d34L; 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 S230492AbiJSIlK (ORCPT + 99 others); Wed, 19 Oct 2022 04:41:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230274AbiJSIj4 (ORCPT ); Wed, 19 Oct 2022 04:39:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92CA881680; Wed, 19 Oct 2022 01:39:02 -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 BAB34617D4; Wed, 19 Oct 2022 08:38:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEDBCC433D6; Wed, 19 Oct 2022 08:38:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168710; bh=FAUBq+xOHHhAmdDXr0nUjCQSE5N3RTGbcKi+sVW2no4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sa31d34L4KSDEg5qe1UPJe5rnJ4ASjaN1pJf1osSgrruA+TE9m7P+CbI7TsmYVmz9 vYfdQJvJiyGAc9sFOVQLKbPcTUynFi3dX+gVhYcv7DLrelbd41Ruq5NenbkcDYxGyA bNT5BkmPkwDXzuxVWUUiY3G3B8EM6pTtTbNvQBlw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 6.0 003/862] ALSA: usb-audio: Fix potential memory leaks Date: Wed, 19 Oct 2022 10:21:30 +0200 Message-Id: <20221019083250.136257599@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747104762186638187?= X-GMAIL-MSGID: =?utf-8?q?1747104762186638187?= 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: