From patchwork Sun Sep 3 12:41:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13373239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D685C71153 for ; Sun, 3 Sep 2023 12:44:01 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3B88C10E; Sun, 3 Sep 2023 14:43:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3B88C10E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1693745038; bh=fkT7NN9aEka8o3o986AJ2AXPaAwyFxw3rtZ6pKH9uYI=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=KYEF+JWNX6ojF3yGaPUuq5iiKX5KmhPKDXErx3ZDMvJnjAcalooLzE7OhLyJAW2Tx o+pOGczktwVgpCNV+Iefi2ElvI1Y52XjBFQm2GQU+186kR5+OQExTOQIO6GSgAC+lH e3AEyAyJWJO3g6toGOWfCpv4RfTDGGu+VhSEDLQ4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C986BF80552; Sun, 3 Sep 2023 14:43:07 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id A2735F8047D; Sun, 3 Sep 2023 14:43:06 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 577B6F8047D; Sun, 3 Sep 2023 14:41:56 +0200 (CEST) Received: from smtp.smtpout.orange.fr (smtp-18.smtpout.orange.fr [80.12.242.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7A30FF80236 for ; Sun, 3 Sep 2023 14:41:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7A30FF80236 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=wanadoo.fr header.i=@wanadoo.fr header.a=rsa-sha256 header.s=t20230301 header.b=p3cOoNST Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id cmQEqRX1vhaW6cmQEq3SIb; Sun, 03 Sep 2023 14:41:50 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1693744910; bh=PHniSO2zYUYgC/x8zH3jPDQE+1EC8XtwBC0f5Q2U7xI=; h=From:To:Cc:Subject:Date; b=p3cOoNSTCEea5D5oUBy6qdvbEiqZFrWMjMElRRmZoMrmpAH4hBl2M8hACnmdhqJ1i EyCgf1nubhvpvq8HCStgz6nhrJ46QIxGmTJEQmbJfozESIV2/yenVMQxiPmpqLnRpj PlxRM3AyqRlwAJyihfsYOvfZsbjQhcWuE7fs3KqTRvGjKFNEJz2VMwNqCbt28PZspL As87C0CVcy08dt5rfQ77esx7au0YZbXMUtAmJW7NaeuKfc7f/wIP5CEu6bBn+YXVZM CGxdk1/HBxGPwRSVWbIMvxjpTyvFGS+kv6fnQqZQ7lWsBhs4wA6qCVnG1LMEmwVwDw OSJT2CuRgTevg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 03 Sep 2023 14:41:50 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: "Geoffrey D. Bennett" , Jaroslav Kysela , Takashi Iwai Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , Takashi Iwai , alsa-devel@alsa-project.org Subject: [PATCH] ALSA: scarlett2: Fix a potential memory leak in scarlett2_init_notify() Date: Sun, 3 Sep 2023 14:41:45 +0200 Message-Id: <73aab53d53df156a5df2bc61314ff26448526749.1693744859.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Message-ID-Hash: RSXKAVBYCM5OXT6IO54YXUEZPFGVTUHW X-Message-ID-Hash: RSXKAVBYCM5OXT6IO54YXUEZPFGVTUHW X-MailFrom: christophe.jaillet@wanadoo.fr X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: If kmalloc() fails, we should release 'mixer->urb'. Fixes: 9e4d5c1be21f ("ALSA: usb-audio: Scarlett Gen 2 mixer interface") Signed-off-by: Christophe JAILLET --- sound/usb/mixer_scarlett_gen2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c index 9d11bb08667e..a439c7f64b2e 100644 --- a/sound/usb/mixer_scarlett_gen2.c +++ b/sound/usb/mixer_scarlett_gen2.c @@ -4060,8 +4060,10 @@ static int scarlett2_init_notify(struct usb_mixer_interface *mixer) return -ENOMEM; transfer_buffer = kmalloc(private->wMaxPacketSize, GFP_KERNEL); - if (!transfer_buffer) + if (!transfer_buffer) { + usb_free_urb(mixer->urb); return -ENOMEM; + } usb_fill_int_urb(mixer->urb, dev, pipe, transfer_buffer, private->wMaxPacketSize,