WSL2-Linux-Kernel/drivers/edac
Jarkko Lavinen 09a81269c7 i82875p_edac: fix module remove
Fix module removal bugs of i82875p_edac.  Also i82975x_edac code seems to
have the same module removal bugs as in i82875p_edac.

The problems were:

1. In module removal i82875p_remove_one() is never called.

   Variable i82875p_registered is newer changed from 1, which
   guarantees i82875p_remove_one() is not called (and even if it were
   called, it would be called in wrong order).

   As a result, the edac_mc workque is not stopped and keeps probing.
   If kernel debugging options are not enabled, user may not notice
   anything going wrong.

   if debugging options are enabled and I do "rmmod i82875p_edac", I
   get:

      edac debug: edac_pci_workq_function() checking
      BUG: unable to handle kernel paging request at f882d16f
      ...
      call trace:
       [<f8834df3>] ? edac_mc_workq_function+0x55/0x7e [edac_core]
       [<c0233974>] ? run_workqueue+0xd7/0x1a5
       [<c023392f>] ? run_workqueue+0x92/0x1a5
       [<f8834d9e>] ? edac_mc_workq_function+0x0/0x7e [edac_core]
       [<c0233af9>] ? worker_thread+0xb7/0xc3
       [<c0236a7b>] ? autoremove_wake_function+0x0/0x33
       [<c0233a42>] ? worker_thread+0x0/0xc3
       [<c0236809>] ? kthread+0x3b/0x61
       [<c02367ce>] ? kthread+0x0/0x61
       [<c0204587>] ? kernel_thread_helper+0x7/0x10

   Fix for this is to get rid of needles variable i82875p_registered
   altogether and run i82875p_remove_one() *before*
   pci_unregister_driver().

2. edac_mc_del_mc() uses mci after freeing mci

   edac_mc_del_mc() calls calls edac_remove_sysfs_mci_device().  The
   kobject refcount of mci drops to 0 and mci is freed.  After this
   mci is accessed via debug print and i82875p_remove_one() still
   uses mci->pvt and tries to free mci again with edac_mc_free().

   The fix for this is add kobject_get(&mci->edac_mci_kobj) after
   edac_mc_alloc(). Then the mci is still available after returning
   from edac_mc_del_mc() with refcount 1, and mci->pvt is still
   available. When i82875p_remove_one() finally calls edac_mc_free(),
   this will cause kobject_put() and mci is released properly.

Signed-off-by: Jarkko Lavinen <jlavi@iki.fi>
Cc: Doug Thompson <norsk5@yahoo.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-12-01 19:55:25 -08:00
..
Kconfig edac x38: new MC driver module 2008-10-30 11:38:45 -07:00
Makefile edac x38: new MC driver module 2008-10-30 11:38:45 -07:00
amd76x_edac.c edac: fix module initialization on several modules 2nd time 2008-04-29 08:06:26 -07:00
cell_edac.c edac: fix enabling of polling cell module 2008-10-30 11:38:46 -07:00
e7xxx_edac.c edac: fix module initialization on several modules 2nd time 2008-04-29 08:06:26 -07:00
e752x_edac.c edac: e752x fix too loud on nonmemory errors 2008-07-25 10:53:49 -07:00
edac_core.h removed unused #include <linux/version.h>'s 2008-08-23 12:14:12 -07:00
edac_device.c dev_name introduction fall out fix 2008-05-05 15:08:38 -07:00
edac_device_sysfs.c Kobject: convert drivers/* from kobject_unregister() to kobject_put() 2008-01-24 20:40:40 -08:00
edac_mc.c dev_name introduction fall out fix 2008-05-05 15:08:38 -07:00
edac_mc_sysfs.c edac: core fix added newline to sysfs dimm labels 2008-07-25 10:53:49 -07:00
edac_module.c Driver core: change sysdev classes to use dynamic kobject names 2008-01-24 20:40:40 -08:00
edac_module.h edac: remove unneeded functions and add static accessor 2008-04-29 08:06:26 -07:00
edac_pci.c dev_name introduction fall out fix 2008-05-05 15:08:38 -07:00
edac_pci_sysfs.c edac: core fix to use dynamic kobject 2008-07-25 10:53:48 -07:00
edac_stub.c drivers/edac: code tidying on export-gpl 2007-07-19 10:04:57 -07:00
i3000_edac.c edac: fix module initialization on several modules 2nd time 2008-04-29 08:06:26 -07:00
i5000_edac.c i5000-edac: hold reference to mci kobject 2008-11-12 17:17:16 -08:00
i5100_edac.c edac: i5100: cleanup 2008-07-25 10:53:48 -07:00
i82443bxgx_edac.c edac: make i82443bxgx_edac coexist with intel_agp 2008-10-16 11:21:48 -07:00
i82860_edac.c edac: fix module initialization on several modules 2nd time 2008-04-29 08:06:26 -07:00
i82875p_edac.c i82875p_edac: fix module remove 2008-12-01 19:55:25 -08:00
i82975x_edac.c edac: fix module initialization on several modules 2nd time 2008-04-29 08:06:26 -07:00
mpc85xx_edac.c edac mpc85xx: add support for mpc8572 2008-10-16 11:21:48 -07:00
mpc85xx_edac.h drivers-edac: add freescale mpc85xx driver 2008-02-07 08:42:23 -08:00
mv64x60_edac.c edac: mv64x60 add pci fixup 2008-07-25 10:53:49 -07:00
mv64x60_edac.h drivers-edac: add marvell mv64x60 driver 2008-02-07 08:42:23 -08:00
pasemi_edac.c pasemi_edac needs to include linux/edac.h 2008-04-29 19:06:57 -07:00
r82600_edac.c edac: fix module initialization on several modules 2nd time 2008-04-29 08:06:26 -07:00
x38_edac.c edac x38: new MC driver module 2008-10-30 11:38:45 -07:00