Skip to content

Commit

Permalink
EDAC: Fix kernel panic on module unloading
Browse files Browse the repository at this point in the history
This patch fixes use-after-free and double-free bugs in
edac_mc_sysfs_exit(). mci_pdev has single reference and put_device()
calls mc_attr_release() which calls kfree(). The following
device_del() works with already released memory. An another kfree() in
edac_mc_sysfs_exit() releses the same memory again. Great.

Signed-off-by: Konstantin Khlebnikov <[email protected]>
Cc: [email protected] # 3.[67]
Cc: Denis Kirjanov <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Link: http://lkml.kernel.org/r/20121214110310.11019.21098.stgit@zurg
Signed-off-by: Borislav Petkov <[email protected]>
  • Loading branch information
koct9i authored and Borislav Petkov committed Jan 7, 2013
1 parent d1c3ed6 commit 311bd84
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/edac/edac_mc_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,7 @@ int __init edac_mc_sysfs_init(void)

void __exit edac_mc_sysfs_exit(void)
{
put_device(mci_pdev);
device_del(mci_pdev);
put_device(mci_pdev);
edac_put_sysfs_subsys();
kfree(mci_pdev);
}

0 comments on commit 311bd84

Please sign in to comment.