From patchwork Mon Oct 24 11:28:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9107 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp456092wru; Mon, 24 Oct 2022 06:33:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6GrqqDxoHMEZB7tboEgj8j93xShWf4lw5xQ4DwWr1qJFf8dxF/6KljExzopJLa/y0VL9Yi X-Received: by 2002:a17:902:64c1:b0:186:827e:a0da with SMTP id y1-20020a17090264c100b00186827ea0damr15964898pli.94.1666618413499; Mon, 24 Oct 2022 06:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618413; cv=none; d=google.com; s=arc-20160816; b=Hih8Zwj/6fyDc5LnU+P02/3tUuWsIMWHAgdT5LcpgUnsTJ56Gtxa9JGh/5A1kOfdY1 HX5oui7aKba5UDnpi64pA/oNq4+9qkQ2ku8MnF9iCPG4iWYauoRmTpPEXnJwqz28vEzD OheHFCoqUk5jgywn7nV7EBDEZDAFtXE/GDScvJeXNSn4ok2GKjUFy/kMAhfxrPqi0K7l cWNteNc2Sog85/YhnYV6jOjl6xxydroDnCgdDchxub3He1DuhhAehEk8t64xn6YFmojW V1nlG2biR2B13sz5lrBlqzefbCnfyveIPvpYi2lQBa+jp5Q5ATwizjoY14d3IqQJZc6H 1e1Q== 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=G9QD/wg/KrzCV4UvgbmU8/IuGt7DfqZU+XESYSAwNaU=; b=W1k1yypurP4JL3XbWx8kbmu17eciznRTaT679mHFfbBouV4+kU6DBHJNOn4dB/YO+/ dbtBSvYX1G6qCj8rucHPszuW95VIIyyR/iSvVd/NmPqQ/wKFgRZmTU/AQGmoQN+1x0r/ WvzUe3JtkQCI8LzuOCk0cFp2Q3OWlypAxk3cHJtQ2tsDlUoj1tspguy09pl6AZs8wn7K 0SvK4qbMmYjHweiA2B8S/aAiXiZUyN34pMwe1jcVaMUmp2tcPte5xqusgkdu02DNOeBT Rwi3s86YohjHkqqc+7cniIz0+UHSQC6rZKTBKfQj0LkkLVD2hnRmdI5naT4xTUG+piSF N56A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kl7wiOgk; 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 g12-20020a63be4c000000b0043c075717a1si38291180pgo.361.2022.10.24.06.33.20; Mon, 24 Oct 2022 06:33:33 -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=kl7wiOgk; 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 S235918AbiJXNRK (ORCPT + 99 others); Mon, 24 Oct 2022 09:17:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235858AbiJXNQO (ORCPT ); Mon, 24 Oct 2022 09:16:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD9FEA3BB8; Mon, 24 Oct 2022 05:26:03 -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 5F1D1B8119C; Mon, 24 Oct 2022 12:05:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBE9FC433D6; Mon, 24 Oct 2022 12:05:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613140; bh=pAwobHGd7rI9q02A/QyEcxD2Xk97vhOaQ/88etUXOkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kl7wiOgk3TWOZAq5uIez1bmi86pshSJYLYBXLC5Zc2H9ixUPPrpNLA5bEaLJvQREw CHgf0to9C5yj3FpVKfZpxpM4txQbIkZIpfv2f7ly5GZcsT8itHegMjBqlruHBzY5K7 WV98Ctq98kzpLXVcIFHeMaitqUhQm+rMqFIGBhOk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 5.4 003/255] ALSA: usb-audio: Fix potential memory leaks Date: Mon, 24 Oct 2022 13:28:33 +0200 Message-Id: <20221024113002.575449452@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747576069316272706?= X-GMAIL-MSGID: =?utf-8?q?1747576069316272706?= 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 @@ -977,6 +977,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; @@ -996,8 +997,6 @@ static int sync_ep_set_params(struct snd u->urb->complete = snd_complete_urb; } - ep->nurbs = SYNC_URBS; - return 0; out_of_memory: