]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mfd: mc13xxx-core: Fix memory leak in mc13xxx_add_subdevice_pdata()
authorAbdun Nihaal <nihaal@cse.iitm.ac.in>
Tue, 20 Jan 2026 10:26:20 +0000 (15:56 +0530)
committerLee Jones <lee@kernel.org>
Wed, 25 Mar 2026 12:44:43 +0000 (12:44 +0000)
The memory allocated for cell.name using kmemdup() is not freed when
mfd_add_devices() fails. Fix that by using devm_kmemdup().

Fixes: 8e00593557c3 ("mfd: Add mc13892 support to mc13xxx")
Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
Link: https://patch.msgid.link/20260120102622.66921-1-nihaal@cse.iitm.ac.in
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/mc13xxx-core.c

index 920797b806ced8b9e63a8e8071e75d46c3355872..786eab3b2d03c62e7ec6f2196ff19e1044c5be93 100644 (file)
@@ -377,7 +377,7 @@ static int mc13xxx_add_subdevice_pdata(struct mc13xxx *mc13xxx,
        if (snprintf(buf, sizeof(buf), format, name) > sizeof(buf))
                return -E2BIG;
 
-       cell.name = kmemdup(buf, strlen(buf) + 1, GFP_KERNEL);
+       cell.name = devm_kmemdup(mc13xxx->dev, buf, strlen(buf) + 1, GFP_KERNEL);
        if (!cell.name)
                return -ENOMEM;