s390/ccwgroup: obtain extra reference for asynchronous processing
authorSebastian Ott <sebott@linux.vnet.ibm.com>
Fri, 13 Jun 2014 15:02:24 +0000 (17:02 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Mon, 16 Jun 2014 08:32:24 +0000 (10:32 +0200)
Commit 0b60f9ead5d4816e7e3d6e28f4a0d22d4a1b2513
"s390: use device_remove_file_self() instead of device_schedule_callback()"
changed ccwgroup to use an extra work queue instead of
device_schedule_callback. This function obtained an extra device
reference for its async work which is missing in the new implementation
and results in a "freeing memory with a lock still held" BUG. Fix
this by obtaining an extra reference for the async work.

Reported-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/cio/ccwgroup.c

index dfd7bc681c255d62f07b6471048a8342388c78bd..040e643746aa5be7761a003869ef6c8395b124d6 100644 (file)
@@ -227,6 +227,7 @@ static void ccwgroup_ungroup_workfn(struct work_struct *work)
                container_of(work, struct ccwgroup_device, ungroup_work);
 
        ccwgroup_ungroup(gdev);
+       put_device(&gdev->dev);
 }
 
 static void ccwgroup_release(struct device *dev)
@@ -412,8 +413,10 @@ static int ccwgroup_notifier(struct notifier_block *nb, unsigned long action,
 {
        struct ccwgroup_device *gdev = to_ccwgroupdev(data);
 
-       if (action == BUS_NOTIFY_UNBIND_DRIVER)
+       if (action == BUS_NOTIFY_UNBIND_DRIVER) {
+               get_device(&gdev->dev);
                schedule_work(&gdev->ungroup_work);
+       }
 
        return NOTIFY_OK;
 }