Skip to content

Commit

Permalink
PCI hotplug: ibmphp: Fix module ref count underflow
Browse files Browse the repository at this point in the history
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: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
  • Loading branch information
Neil Horman authored and Jesse Barnes committed Dec 18, 2008
1 parent b6adc19 commit 3e3d0e9
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions drivers/pci/hotplug/ibmphp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1402,10 +1402,6 @@ static int __init ibmphp_init(void)
goto error;
}

/* lock ourselves into memory with a module
* count of -1 so that no one can unload us. */
module_put(THIS_MODULE);

exit:
return rc;

Expand All @@ -1423,4 +1419,3 @@ static void __exit ibmphp_exit(void)
}

module_init(ibmphp_init);
module_exit(ibmphp_exit);

0 comments on commit 3e3d0e9

Please sign in to comment.