* [PATCH] edac: fix memory leaks on failure path in edac_init()
@ 2015-02-06 6:12 Alexey Khoroshilov
2015-02-06 11:50 ` Borislav Petkov
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Khoroshilov @ 2015-02-06 6:12 UTC (permalink / raw)
To: Doug Thompson, Borislav Petkov, Mauro Carvalho Chehab
Cc: Alexey Khoroshilov, linux-edac, linux-kernel, ldv-project
edac_init() does not deallocate already allocated resources on failure path.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
drivers/edac/edac_module.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/edac/edac_module.c b/drivers/edac/edac_module.c
index e6d1691dfa45..a256dcb31d03 100644
--- a/drivers/edac/edac_module.c
+++ b/drivers/edac/edac_module.c
@@ -112,7 +112,7 @@ static int __init edac_init(void)
err = edac_mc_sysfs_init();
if (err)
- goto error;
+ goto err_sysfs;
edac_debugfs_init();
@@ -120,12 +120,15 @@ static int __init edac_init(void)
err = edac_workqueue_setup();
if (err) {
edac_printk(KERN_ERR, EDAC_MC, "init WorkQueue failure\n");
- goto error;
+ goto err_wq;
}
return 0;
-error:
+err_wq:
+ edac_debugfs_exit();
+ edac_mc_sysfs_exit();
+err_sysfs:
return err;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] edac: fix memory leaks on failure path in edac_init()
2015-02-06 6:12 [PATCH] edac: fix memory leaks on failure path in edac_init() Alexey Khoroshilov
@ 2015-02-06 11:50 ` Borislav Petkov
2015-02-11 12:02 ` Borislav Petkov
0 siblings, 1 reply; 3+ messages in thread
From: Borislav Petkov @ 2015-02-06 11:50 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Doug Thompson, Mauro Carvalho Chehab, linux-edac, linux-kernel,
ldv-project
On Thu, Feb 05, 2015 at 10:12:42PM -0800, Alexey Khoroshilov wrote:
> edac_init() does not deallocate already allocated resources on failure path.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Thanks, queued for 3.21.
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] edac: fix memory leaks on failure path in edac_init()
2015-02-06 11:50 ` Borislav Petkov
@ 2015-02-11 12:02 ` Borislav Petkov
0 siblings, 0 replies; 3+ messages in thread
From: Borislav Petkov @ 2015-02-11 12:02 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Doug Thompson, Mauro Carvalho Chehab, linux-edac, linux-kernel,
ldv-project
On Fri, Feb 06, 2015 at 12:50:53PM +0100, Borislav Petkov wrote:
> On Thu, Feb 05, 2015 at 10:12:42PM -0800, Alexey Khoroshilov wrote:
> > edac_init() does not deallocate already allocated resources on failure path.
> >
> > Found by Linux Driver Verification project (linuxtesting.org).
> >
> > Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
This causes section mismatches because the
edac_{debugfs,mc_sysfs}_exit() functions have __exit annotation but
you've added them to an __init-annotated function. And I should've
caught that :-\
Anyway, here's a fix I'm queueing ontop:
---
From: Borislav Petkov <bp@suse.de>
Subject: [PATCH] EDAC: Fix section mismatches from edac_init unwind path
192580b45e8e ("EDAC: Properly unwind on failure path in edac_init()")
added an unwind path in case of error but those functions have __exit
annotation and are being used in an __init function, leading to section
mismatches. Drop the section annotation and make them normal functions.
Cc: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Borislav Petkov <bp@suse.de>
---
drivers/edac/edac_mc_sysfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 3a283819970b..112d63ad1154 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -914,7 +914,7 @@ int __init edac_debugfs_init(void)
return 0;
}
-void __exit edac_debugfs_exit(void)
+void edac_debugfs_exit(void)
{
debugfs_remove(edac_debugfs);
}
@@ -1155,7 +1155,7 @@ int __init edac_mc_sysfs_init(void)
return err;
}
-void __exit edac_mc_sysfs_exit(void)
+void edac_mc_sysfs_exit(void)
{
device_unregister(mci_pdev);
edac_put_sysfs_subsys();
--
2.2.0.33.gc18b867
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-02-11 12:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-06 6:12 [PATCH] edac: fix memory leaks on failure path in edac_init() Alexey Khoroshilov
2015-02-06 11:50 ` Borislav Petkov
2015-02-11 12:02 ` Borislav Petkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).