From patchwork Mon Oct 24 11:29:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8687 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp422453wru; Mon, 24 Oct 2022 05:22:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6X/Wd0XMW3+lmYLAmI91G8PgJbAckWhq7ohxcskqB6EW3hNs2s2x8FvX9lbCn8VrA6oWbf X-Received: by 2002:a05:6402:1906:b0:45d:db20:7709 with SMTP id e6-20020a056402190600b0045ddb207709mr29781979edz.406.1666614163813; Mon, 24 Oct 2022 05:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666614163; cv=none; d=google.com; s=arc-20160816; b=n+9NXM5YO43zGZV9CgwnIO3u4KhojZne8i6EPMoal2YS8ct9AP11gXG6A0ZIxQHoFV GBW7WKEY5HSdC0JzTaPVFUaoeQznJdXuoXlo8yORRQ1aY7IiE6YCygDVS89lrL1TIwsQ qmEaQPzh5Z1qOIu1gn5xoF0YSS/spn8DE+0pgxvq9YlrZHR/0/4ZbOZqfz9YzkkVbyEo iV4scMx5xvifYU65oVGwbpnF+ruZ7bWkrZmrbwPjRdzCZnzluQBf5ik/N4byL1SG1sXs ocHc8O5/uxPxMWDlaJ9kyS7ZoHA8mjK8t9bRjj/Z8mBrfyx8XXhPRwOOAXwCTB3oaLQ7 cIlA== 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=LLIRqXNUq9qxGPpZxoEFbMqvsp6UGVM0k/gVAKOl0/Q=; b=0LjLv5pDAT8GfUpHUgYYp14k2/KhrupXLjtVcKMHDELrGDE5VXPDnQbW8TVpYzJuDx fPQ9cuvsq/+gOE3p7gHHXchHNlrT/t+wU3xMvZFOX4YUbZz1gMXUkSIQQ8VxDFGW3vWo 09z0AmocmX9Q8cBEoq9vDRrlLdv6IFikB++Bv5b4KWkVnTKWwN6s4/wS/IjxfDV6Vd3o DqkPiXuXEANAWwUpsaTeu++c97nNZ+bQLrXX2IO+5zfRd4OyyEfAVhP/Y7a5cuixOJEd HqY2wWYJ3H436Rda+aGy4ziTe9Tz6VapDqxeQov/upHUYQGiyVLwIQ4OFO1dI8Hdb/sK Q2SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UYTyzqvK; 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 dn3-20020a17090794c300b007806a130086si26627745ejc.302.2022.10.24.05.22.19; Mon, 24 Oct 2022 05:22: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=UYTyzqvK; 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 S233285AbiJXMVL (ORCPT + 99 others); Mon, 24 Oct 2022 08:21:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233409AbiJXMTZ (ORCPT ); Mon, 24 Oct 2022 08:19:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22F4882D29; Mon, 24 Oct 2022 04:58: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 BA24161252; Mon, 24 Oct 2022 11:56:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9C24C433D7; Mon, 24 Oct 2022 11:56:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612561; bh=alxBghWNnhholB3VzlLrbDxYywOEImlsaWDNbu24k10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UYTyzqvKbAppaqqepP5BwAh2zDAx82l6o7DbzWgtrrz/7cGvEMs0eqmbvtxCeZzkN KAOVP5Fbn7rX5phAJXcKmX/AY7HaI0BvXfEohFYoVWg+t9+E1dGHr16x2B+I5Svl+A PnvmOpzrS9ytw/HGavb8tn9w8vvELSUMknfmjsrk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 4.19 034/229] ALSA: usb-audio: Fix potential memory leaks Date: Mon, 24 Oct 2022 13:29:13 +0200 Message-Id: <20221024113000.217616844@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@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?1747571613366435930?= X-GMAIL-MSGID: =?utf-8?q?1747571613366435930?= 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 @@ -816,6 +816,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; @@ -835,8 +836,6 @@ static int sync_ep_set_params(struct snd u->urb->complete = snd_complete_urb; } - ep->nurbs = SYNC_URBS; - return 0; out_of_memory: