From nobody Mon Dec 15 23:27:41 2025 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F9462E54AA; Mon, 15 Dec 2025 09:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765789538; cv=none; b=Wt/wZMC1tK76jUQH03nAur/1rbiV5vYyYf1xX4pJ/eXcVnWbr56pzUnGShqxJYi2HoKLKh6/1MF7unM5/p9LfoieSEq56Q50Y6sAIsdjRvD7s8n1kWHA1k3b4Fe46+eR7fMwWBBH8ZO1RAf6cVu8pQbvwsxOv0hFC88+fXsj0uA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765789538; c=relaxed/simple; bh=ZEQeQjl4kHPYFc1IFVPPj85mT+KhEXHtFDGGqqo+v0o=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EoV/4f8NpaOpo6LBrNdDiNOY3KmN9Sm/yswVfIwtJyNB/gn+tMM3r4WZ7sR+0yuvoKy0BtRolR5o84+iDjgAk7GtE09x8jd86WlMdAniqTOzpOAM+bumKwAJTpvMEyMrLltDCL0o9b6x4kuodJwIYrgm8syKXtRsF0cCT8E6wOE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from DESKTOP-L0HPE2S (unknown [124.16.141.245]) by APP-01 (Coremail) with SMTP id qwCowABX_mlXzz9pcKS5AA--.2268S2; Mon, 15 Dec 2025 17:05:29 +0800 (CST) From: Haotian Zhang To: perex@perex.cz, tiwai@suse.com Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Haotian Zhang , Takashi Iwai Subject: [PATCH] ALSA: pcmcia: Fix resource leak in snd_pdacf_probe error path Date: Mon, 15 Dec 2025 17:04:33 +0800 Message-ID: <20251215090433.211-1-vulab@iscas.ac.cn> X-Mailer: git-send-email 2.50.1.windows.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qwCowABX_mlXzz9pcKS5AA--.2268S2 X-Coremail-Antispam: 1UD129KBjvdXoW7XF18KrW3KFW5WFWfKF1rJFb_yoWkArc_Cw 4IgFyDtr1qgayI934fCa4rCaySya1UCF1kWFWrta17A39FganFqryDWrnrurn7Z3ykAry7 WFn2vr12vasFyjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbsxFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_ Gr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkF7I0En4kS14v26r12 6r1DMxkIecxEwVAFwVW8uwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8Jw C20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAF wI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjx v20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2 jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0x ZFpf9x0JU8ucNUUUUU= X-CM-SenderInfo: pyxotu46lvutnvoduhdfq/1tbiBgoRA2k-u2dOxAAAse Content-Type: text/plain; charset="utf-8" When pdacf_config() fails, snd_pdacf_probe() returns the error code directly without freeing the sound card resources allocated by snd_card_new(), which leads to a memory leak. Add proper error handling to free the sound card and clear the card list entry when pdacf_config() fails. Fixes: 15b99ac17295 ("[PATCH] pcmcia: add return value to _config() functio= ns") Suggested-by: Takashi Iwai Signed-off-by: Haotian Zhang --- sound/pcmcia/pdaudiocf/pdaudiocf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pd= audiocf.c index 13419837dfb7..a3291e626440 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c @@ -131,7 +131,13 @@ static int snd_pdacf_probe(struct pcmcia_device *link) link->config_index =3D 1; link->config_regs =3D PRESENT_OPTION; =20 - return pdacf_config(link); + err =3D pdacf_config(link); + if (err < 0) { + card_list[i] =3D NULL; + snd_card_free(card); + return err; + } + return 0; } =20 =20 --=20 2.50.1.windows.1