From patchwork Mon Oct 24 11:29:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8750 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp430097wru; Mon, 24 Oct 2022 05:40:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5BhY0/O5Ze9tInNQ1pxeh5M4ZUauHALwNfHwP29Q/yakEx6DeWlcEAAJinMuQEQoWCjNQv X-Received: by 2002:a17:90a:50:b0:20a:b146:e75e with SMTP id 16-20020a17090a005000b0020ab146e75emr38256022pjb.216.1666615243702; Mon, 24 Oct 2022 05:40:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615243; cv=none; d=google.com; s=arc-20160816; b=Rvjqdjt0z7amWcRKx9u5Q1P7u9ZMyY0V+l7Kb4BKobyPMisokwP338x0xdPnw2sqoI PBdUBd68valoVwfZdJzsKDM32tYPb129jjMqE18Py1Q8kZ6lmOvmx9QKD6NAO+Ru+9qh yG2PeOPyZ5krMVeROxmhS8owV98pDl31iEUnjSg6JgC1Ah+Gt2Hd+GLzNcCF2E6WJ/Pa 45c69sW+IOuRl8SB79zuQQEuAk3P/2AEtsbvr+MnMCo9sf1ati01X6jfvBywkm1YCxaY bWeg4nK5aso6eQ/7rQlGz2hzMS0ZshvMb1+DA0iclV1FatKe2Mi2uBwGOoT+Um+b7F3f v7lw== 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=d8s4Zdm8FBu20t6bUJd/AmtKBBB8zNwX+itxgi6fvKE=; b=ABHmlIKmyxjRp06aWC90mImhFAP84Z+LjjyOo7ABPdJh3AmQ5mNJngAcrzOA/xUX5p eztImOMEDMy9ECPqIf62RI08ZkvIIL+1aLJ841RfU+bmRjGohx4kCs9E5huMXVqaDvk6 4ZuifyiAYA8cOMNweh+UwTvxnvQ48yj/bbzP9C5HQ+kTshOxuzLdYshQhOFIXyUk/3yo dn6BdyYQpd1cnLjGkIlOuu6WM15TJ07GId57kv2V+AvsnM+S/CbYIJaSI4S4c88cO+Ct ufrQYxgf8wq5buCoUNbS+OoCYZNDQX36a5EAqirXCycpDNqjd4z7Easf6/S5/U5G84e9 MzcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wcIvQc3K; 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 oj17-20020a17090b4d9100b002132abf9ad6si874034pjb.148.2022.10.24.05.40.28; Mon, 24 Oct 2022 05:40:43 -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=wcIvQc3K; 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 S231731AbiJXMZ7 (ORCPT + 99 others); Mon, 24 Oct 2022 08:25:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233836AbiJXMYZ (ORCPT ); Mon, 24 Oct 2022 08:24:25 -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 5C79842D4E; Mon, 24 Oct 2022 05:00:11 -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 B13B2612BE; Mon, 24 Oct 2022 11:47:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5EF2C433C1; Mon, 24 Oct 2022 11:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612054; bh=KJ2cmYkVYWZemHCOGauIePDWAFHhV8/OUEmdQkb57Tg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wcIvQc3KZbUVP1t7qSepJvV+67QLsEvUdAgf54bjboFn/wI1bL+jbhRlib0GdQKlU rH/LEva47UNFNVpWroEIOqch2o4d/pQnrkGa1SDEETY0WwrRguxP8PVXk8e5o63zdJ W0FoKMOQMTHsYyMrDSju6DVW6XPeVLACHkXqmxUc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 4.14 052/210] ALSA: usb-audio: Fix potential memory leaks Date: Mon, 24 Oct 2022 13:29:29 +0200 Message-Id: <20221024112958.689353440@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@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?1747572745444962584?= X-GMAIL-MSGID: =?utf-8?q?1747572745444962584?= 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 @@ -818,6 +818,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; @@ -837,8 +838,6 @@ static int sync_ep_set_params(struct snd u->urb->complete = snd_complete_urb; } - ep->nurbs = SYNC_URBS; - return 0; out_of_memory: