FAILED: patch "[PATCH] mfd: sm501: Fix potential memory leaks during remove" failed to apply to 5.15-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 83feedd9d83c0c5199f98c72df0a6196b4aefb4d
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090352-reptile-skyline-e58f@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 83feedd9d83c0c5199f98c72df0a6196b4aefb4d Mon Sep 17 00:00:00 2001
From: Abdun Nihaal <[email protected]>
Date: Mon, 20 Jul 2026 17:08:32 +0530
Subject: [PATCH] mfd: sm501: Fix potential memory leaks during remove
The memory allocated for struct sm501_devdata in sm501_pci_probe() and sm501_plat_probe() is not freed by the corresponding remove functions sm501_pci_remove() and sm501_plat_remove(). Fix that by adding a call to kfree().
drivers/mfd/sm501.c +2 -0
@@ -1627,6 +1627,7 @@ static void sm501_pci_remove(struct pci_dev *dev)release_mem_region (sm->io_res->start,0x100 );pci_disable_device (dev); +kfree (sm); }static void sm501_plat_remove (struct platform_device *dev)
@@ -1637,6 +1638,7 @@ static void sm501_plat_remove(struct platform_device *dev)iounmap (sm->regs);release_mem_region (sm->io_res->start,0x100 ); +kfree (sm); }static const struct pci_device_id sm501_pci_tbl[] = {
Sasha Levin
maintainerPATCH 1/3 mfd: sm501: Remove #ifdef guards for PM related functions
From: Paul Cercueil <[email protected]>
[ Upstream commit 3833239b5ba22256389c2fd83ca70b6a9028435b ]
Use the new pm_sleep_ptr() macro to handle the .suspend/.resume callbacks.
This macro allow the suspend and resume functions to be automatically dropped by the compiler when CONFIG_SUSPEND is disabled, without having to use #ifdef guards.
This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.
Stable-dep-of: 83feedd9d83c ("mfd: sm501: Fix potential memory leaks during remove")
--- drivers/mfd/sm501.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/mfd/sm501.c +2 -8
@@ -1434,8 +1434,6 @@ static int sm501_plat_probe(struct platform_device *dev) } -#ifdef CONFIG_PM -/* power management support */ static void sm501_set_power (struct sm501_devdata *sm,int on)
@@ -1511,10 +1509,6 @@ static int sm501_plat_resume(struct platform_device *pdev)return 0 ; } -#else -#define sm501_plat_suspend NULL -#define sm501_plat_resume NULL -#endif /* Initialisation data for PCI devices */
@@ -1716,8 +1710,8 @@ static struct platform_driver sm501_plat_driver = { }, .probe = sm501_plat_probe, .remove = sm501_plat_remove, - .suspend = sm501_plat_suspend, - .resume = sm501_plat_resume, + .suspend = pm_sleep_ptr(sm501_plat_suspend), + .resume = pm_sleep_ptr(sm501_plat_resume), };static int __init sm501_base_init (void )
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/3 mfd: sm501: Convert to platform remove callback returning void
From: Uwe Kleine-König <[email protected]>
[ Upstream commit c20fddf7acfb54d856c34208926701d32c25eb18 ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks.
To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove().
Trivially convert this driver from always returning zero in the remove callback to the void returning variant.
Stable-dep-of: 83feedd9d83c ("mfd: sm501: Fix potential memory leaks during remove")
--- drivers/mfd/sm501.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mfd/sm501.c +2 -4
@@ -1669,7 +1669,7 @@ static void sm501_pci_remove(struct pci_dev *dev)pci_disable_device (dev); } -static int sm501_plat_remove (struct platform_device *dev) +static void sm501_plat_remove (struct platform_device *dev) {struct sm501_devdata *sm =platform_get_drvdata (dev);
@@ -1677,8 +1677,6 @@ static int sm501_plat_remove(struct platform_device *dev)iounmap (sm->regs);release_mem_region (sm->io_res->start,0x100 ); - -return 0 ; }static const struct pci_device_id sm501_pci_tbl[] = {
@@ -1709,7 +1707,7 @@ static struct platform_driver sm501_plat_driver = { .of_match_table = of_sm501_match_tbl, }, .probe = sm501_plat_probe, - .remove = sm501_plat_remove, + .remove_new = sm501_plat_remove, .suspend = pm_sleep_ptr(sm501_plat_suspend), .resume = pm_sleep_ptr(sm501_plat_resume), };
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/3 mfd: sm501: Fix potential memory leaks during remove
In reply to Sasha LevinFrom: Abdun Nihaal <[email protected]>
[ Upstream commit 83feedd9d83c0c5199f98c72df0a6196b4aefb4d ]
The memory allocated for struct sm501_devdata in sm501_pci_probe() and sm501_plat_probe() is not freed by the corresponding remove functions sm501_pci_remove() and sm501_plat_remove(). Fix that by adding a call to kfree().
--- drivers/mfd/sm501.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mfd/sm501.c +2 -0
@@ -1667,6 +1667,7 @@ static void sm501_pci_remove(struct pci_dev *dev)release_mem_region (sm->io_res->start,0x100 );pci_disable_device (dev); +kfree (sm); }static void sm501_plat_remove (struct platform_device *dev)
@@ -1677,6 +1678,7 @@ static void sm501_plat_remove(struct platform_device *dev)iounmap (sm->regs);release_mem_region (sm->io_res->start,0x100 ); +kfree (sm); }static const struct pci_device_id sm501_pci_tbl[] = {
Signature · 1 line
2.53.0