dect
/
linux-2.6
Archived
13
0
Fork 0

megaraid: fix BUG_ON() from incorrect use of delayed work

megaraid use INIT_WORK to declare a hotplug_work, but cast the
hotplug_work from work_struct to delayed_work and
schedule_delayed_work on it.  This is very dangerous, as other part of
delayed_work might be kernel memories allocated by others.

With commit 8852aac ("workqueue: mod_delayed_work_on() shouldn't queue
timer on 0 delay"), schedule_delayed_work() will check dwork->timer
before queue_work even when @delay is 0, this causes megaraid code to
hit the BUG_ON() in workqueue code.  Change megaraid code to use
delayed work.

Signed-off-by: Xiaotian Feng <dannyfeng@tencent.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Neela Syam Kolli <megaraidlinux@lsi.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: linux-scsi@vger.kernel.org
This commit is contained in:
Xiaotian Feng 2012-12-04 19:33:54 +08:00 committed by Tejun Heo
parent 8852aac25e
commit c1d390d8e6
2 changed files with 7 additions and 9 deletions

View File

@ -1276,7 +1276,7 @@ struct megasas_evt_detail {
} __attribute__ ((packed)); } __attribute__ ((packed));
struct megasas_aen_event { struct megasas_aen_event {
struct work_struct hotplug_work; struct delayed_work hotplug_work;
struct megasas_instance *instance; struct megasas_instance *instance;
}; };

View File

@ -2060,9 +2060,9 @@ megasas_service_aen(struct megasas_instance *instance, struct megasas_cmd *cmd)
} else { } else {
ev->instance = instance; ev->instance = instance;
instance->ev = ev; instance->ev = ev;
INIT_WORK(&ev->hotplug_work, megasas_aen_polling); INIT_DELAYED_WORK(&ev->hotplug_work,
schedule_delayed_work( megasas_aen_polling);
(struct delayed_work *)&ev->hotplug_work, 0); schedule_delayed_work(&ev->hotplug_work, 0);
} }
} }
} }
@ -4352,8 +4352,7 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state)
/* cancel the delayed work if this work still in queue */ /* cancel the delayed work if this work still in queue */
if (instance->ev != NULL) { if (instance->ev != NULL) {
struct megasas_aen_event *ev = instance->ev; struct megasas_aen_event *ev = instance->ev;
cancel_delayed_work_sync( cancel_delayed_work_sync(&ev->hotplug_work);
(struct delayed_work *)&ev->hotplug_work);
instance->ev = NULL; instance->ev = NULL;
} }
@ -4545,8 +4544,7 @@ static void __devexit megasas_detach_one(struct pci_dev *pdev)
/* cancel the delayed work if this work still in queue*/ /* cancel the delayed work if this work still in queue*/
if (instance->ev != NULL) { if (instance->ev != NULL) {
struct megasas_aen_event *ev = instance->ev; struct megasas_aen_event *ev = instance->ev;
cancel_delayed_work_sync( cancel_delayed_work_sync(&ev->hotplug_work);
(struct delayed_work *)&ev->hotplug_work);
instance->ev = NULL; instance->ev = NULL;
} }
@ -5190,7 +5188,7 @@ static void
megasas_aen_polling(struct work_struct *work) megasas_aen_polling(struct work_struct *work)
{ {
struct megasas_aen_event *ev = struct megasas_aen_event *ev =
container_of(work, struct megasas_aen_event, hotplug_work); container_of(work, struct megasas_aen_event, hotplug_work.work);
struct megasas_instance *instance = ev->instance; struct megasas_instance *instance = ev->instance;
union megasas_evt_class_locale class_locale; union megasas_evt_class_locale class_locale;
struct Scsi_Host *host; struct Scsi_Host *host;