From nobody Tue Apr 7 18:02:09 2026 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4150538AC81 for ; Thu, 12 Mar 2026 08:48:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773305282; cv=none; b=Smsy6SmC7ckFDXK8a7riDfm6UqbqetL0axT0dMK7p+zxZW0mmLXD4rzBK+hBp0Go0ZifBCsVVafuFmWB6MXb2GF107s7edSCAuiz+SsIDmRzxCU4EN/NdpSF82wAJHcOp7TSxx1BVbLmmyvGB5FVBBmbuWvL1dtkZmXVQxd75tE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773305282; c=relaxed/simple; bh=jshvpbbqyCJXJFnCiNXC8f1p7ofXuAPUjoLyT+Hay3w=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RosmgPxACfid2fiFb4N3Unry3EQQpVO4XCV8Vy8Rs4IcTDnE3n8sd+bgbm8txQDS81uw1OdAgy8pHjuqrKA4Z/JDc7CZ8UT+5NAMiyuFvRD1OYF6stHUW0+QWhqaHYqNRbPfCeT1+67TFuUKfFT94CGJxrQce/vDHDhvryzrRmE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XzNG5t3f; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XzNG5t3f" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2ae5423b02aso5705855ad.1 for ; Thu, 12 Mar 2026 01:48:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773305281; x=1773910081; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=L+iYefIZxKcaeucX4XcH147M85Qnaa9Ph+8tLAQwycQ=; b=XzNG5t3f34igxRlf/2lzTPx3qRXAuvGRjDTGnjzRUO/xZ41CV6cccJlB2csMSHF/tZ 8+9qqkGzFoxeF+dnDpURB8Lu4uj8/hUpDZ11STBy4wSEvIuMMHvCODFdGfk6jTeKX751 XOmOJeTbTP9UIiSRhTsaYvnJ9wyQoqHTA17LbOCMFTzW7CQrtZSNRwyq3Zjeua84YQAP jkLyb0qacYF83Jz1R4S4k0plxaNKDF6NNGwXDibqLB+7X1u6M3MXzciRaDzvGTQJaWHP nMB6xOa28TFZt/ki8J5EdhGA3Ttc55Aq4GsH5qi4M+R1XngMo5iVcoG4ud//Im9KWNC+ jbFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773305281; x=1773910081; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=L+iYefIZxKcaeucX4XcH147M85Qnaa9Ph+8tLAQwycQ=; b=JLSZ8gsyMEanq74/fNRl3ufnKawGMppdblHBcOC14GA+75sIGdfM0Q2yeMeEkmYLK2 LTQpCnfUBtI02GVGz048Xv0inuvZWdXA8bw7BbKc5wRjCOh24xoVjU2q7G6Yywm6qdm5 zKXo/NhFXCBs9uMFe0LwDwLWbo81S/DSF/hICuS3frCdt2li6ipJ2HlW++KV+0fG7uzl zcizKVi4IMAZ20FpkjdPTaFHjHNy5QQ9qORIB2TexftlMueYu6OJnZtGedB4OU+Txzxl H6lOVxrBd+HI62nsEyrj27G/U7Dyr7OM2KVcWKkxVwv+Pld4DBZLoypTxM8E1PUkZ5F6 wycA== X-Forwarded-Encrypted: i=1; AJvYcCX353pJS9GKfG1fu2hkkCQlzjxCIyXGD0HXYq4y/4JOvS7eWxLcQbVSq6Gggw3jdfvqrv4T4L8yvV2nYPk=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+fTj0fegM2KFD0kXhMqm4mPAmg36J7L6GJtDU18foaxVJuC66 lYM9WsQNlHI+I+L04SkB8xWkz9Enw48vlJT+2Lo7XuV+jHA8ELi54mbd X-Gm-Gg: ATEYQzzchh44V9+/GZYm/z1nJ7MWLrpA0jgn3MtnjdP4mYGepNbFRG2Gb5biWHeJeXe JOHnGnRcxb0FF/mfPKe1qOGsu2PsN5CeWXCjeMP1vkpjd8S+idIZdJZ5/AChunOUNG0kOyTRs39 xdQS7NBEgQhacenH6vPT/enJOuOa6COY2nyh4R8drH0nZn7fNQsEzkuXIObyLHC7onGrlNhxLIS maNIrEuJ4uWkk9dYS0xphG1jS3P26B63ozCCsp/oTldGLTmeNe2eSe/85tINldiyimjY4VPeC9L 45lyeB0uzJFvgEY81FKtvfh5WMkzNfwzAH8T63Md/9zk3GHCR1CdbHWmKzvClFvSM57M1nlhUxe bGHUCNaJNXEdAg2l3DaOstzbxCe5AZHQOKt4yp+Q3+sc6fuHg6iNVZVBtq1G/K3c9DqvYr+ZIrc /VN9TcpO6ao9wcVw== X-Received: by 2002:a17:902:d506:b0:2ae:aa16:acfb with SMTP id d9443c01a7336-2aeae80cc3fmr54507325ad.22.1773305280599; Thu, 12 Mar 2026 01:48:00 -0700 (PDT) Received: from lgs.. ([36.255.193.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2aeae2228easm48508975ad.3.2026.03.12.01.47.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2026 01:48:00 -0700 (PDT) From: Guangshuo Li To: Kiseok Jo , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Chenyuan Yang , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Guangshuo Li , stable@vger.kernel.org Subject: [PATCH] ASoC: sma1307: fix double free of devm_kzalloc() memory Date: Thu, 12 Mar 2026 16:47:49 +0800 Message-ID: <20260312084749.365325-1-lgs201920130244@gmail.com> X-Mailer: git-send-email 2.43.0 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 Content-Type: text/plain; charset="utf-8" A previous change added NULL checks and cleanup for allocation failures in sma1307_setting_loaded(). However, the cleanup for mode_set entries is wrong. Those entries are allocated with devm_kzalloc(), so they are device-managed resources and must not be freed with kfree(). Manually freeing them in the error path can lead to a double free when devres later releases the same memory. Drop the manual kfree() loop and let devres handle the cleanup. Fixes: 0ec6bd16705fe ("ASoC: sma1307: Add NULL check in sma1307_setting_loa= ded()") Cc: stable@vger.kernel.org Signed-off-by: Guangshuo Li --- sound/soc/codecs/sma1307.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/soc/codecs/sma1307.c b/sound/soc/codecs/sma1307.c index 4bb59e5c0891..3a01aca17e75 100644 --- a/sound/soc/codecs/sma1307.c +++ b/sound/soc/codecs/sma1307.c @@ -1759,8 +1759,6 @@ static void sma1307_setting_loaded(struct sma1307_pri= v *sma1307, const char *fil sma1307->set.mode_size * 2 * sizeof(int), GFP_KERNEL); if (!sma1307->set.mode_set[i]) { - for (int j =3D 0; j < i; j++) - kfree(sma1307->set.mode_set[j]); sma1307->set.status =3D false; return; } --=20 2.43.0