Commit 3e3d0e92 authored by Neil Horman's avatar Neil Horman Committed by Jesse Barnes

PCI hotplug: ibmphp: Fix module ref count underflow

I happened to notice that the ibmphp hotplug driver does something
rather silly in its init routine.  It purposely calls module_put so as
to underflow its module ref count to avoid being removed from the
kernel.  This is bad practice, and wrong, since it provides a window for
subsequent module_gets to reset the refcount to zero, allowing an unload
to race in and cause all sorts of mysterious panics.  If the module is
unsafe to load, simply omitting the module_exit parameter is sufficient
to prevent the kernel from allowing the unload.
Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarNeil Horman <nhorman@tuxdriver.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent b6adc195
...@@ -1402,10 +1402,6 @@ static int __init ibmphp_init(void) ...@@ -1402,10 +1402,6 @@ static int __init ibmphp_init(void)
goto error; goto error;
} }
/* lock ourselves into memory with a module
* count of -1 so that no one can unload us. */
module_put(THIS_MODULE);
exit: exit:
return rc; return rc;
...@@ -1423,4 +1419,3 @@ static void __exit ibmphp_exit(void) ...@@ -1423,4 +1419,3 @@ static void __exit ibmphp_exit(void)
} }
module_init(ibmphp_init); module_init(ibmphp_init);
module_exit(ibmphp_exit);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment