From: hiro muneda <tmuneda@redhat.com> Date: Sat, 15 May 2010 01:19:17 -0400 Subject: [fusion] mpt: fix deregister calls in exit path Message-id: <20100515011917.14539.93251.sendpatchset@flat.lab.bos.redhat.com> Patchwork-id: 25121 O-Subject: [RHEL5.6 PATCH 1/1] [SCSI] mpt: modify mptctl_exit() to callproper deregister functions - V2 Bugzilla: 581523 RH-Acked-by: David Milburn <dmilburn@redhat.com> RHBZ#: ====== https://bugzilla.redhat.com/show_bug.cgi?id=581523 Description: ============ insmod mptctl.ko fails when we insmod/rmmod mptctl.ko and other mpt drivers simultaneously. Brew: ===== Successful brew scratch build against each arch. http://brewweb.devel.redhat.com/brew/taskinfo?taskID=2445324 Upstream: ========= In upstream. http://git.kernel.org/?p=linux/kernel/git/jejb/scsi-misc-2.6.git;a=commit;h=65c054f235fda2d545ecd2a7948906a3cf0c1f39 Test status: ============ The patch has been tested by me and fixes the problem. I used the test program which is attached on the Bugzilla. Please review and ACK. Thanks, hiro -- Takahiro MUNEDA Fujitsu on-site engineer Signed-off-by: Jarod Wilson <jarod@redhat.com> diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index 0b74a01..41b0712 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c @@ -2996,6 +2996,14 @@ static int __init mptctl_init(void) } mptctl_taskmgmt_id = mpt_register(mptctl_taskmgmt_reply, MPTCTL_DRIVER); + if (!mptctl_taskmgmt_id || mptctl_taskmgmt_id >= MPT_MAX_PROTOCOL_DRIVERS) { + printk(KERN_ERR MYNAM ": ERROR: Failed to register with Fusion MPT base driver\n"); + mpt_deregister(mptctl_id); + misc_deregister(&mptctl_miscdev); + err = -EBUSY; + goto out_fail; + } + mpt_reset_register(mptctl_id, mptctl_ioc_reset); mpt_event_register(mptctl_id, mptctl_event_process); @@ -3015,12 +3023,15 @@ static void mptctl_exit(void) printk(KERN_INFO MYNAM ": Deregistered /dev/%s @ (major,minor=%d,%d)\n", mptctl_miscdev.name, MISC_MAJOR, mptctl_miscdev.minor); + /* De-register event handler from base module */ + mpt_event_deregister(mptctl_id); + /* De-register reset handler from base module */ mpt_reset_deregister(mptctl_id); /* De-register callback handler from base module */ + mpt_deregister(mptctl_taskmgmt_id); mpt_deregister(mptctl_id); - mpt_reset_deregister(mptctl_taskmgmt_id); mpt_device_driver_deregister(MPTCTL_DRIVER);