s390/dasd: check blockdevice pointer before trying to sync blockdevice
authorStefan Haberland <sth@linux.vnet.ibm.com>
Wed, 25 Jan 2017 15:56:41 +0000 (16:56 +0100)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 31 Jan 2017 09:47:25 +0000 (10:47 +0100)
If safe offline is called for a DASD alias device a null pointer is passed
to fsync_bdev. So check for existence of the blockdevice before calling
fsync_bdev.
Should not be a real world problem since safe offline for an alias device
does not make sense and fsync_bdev can deal with a NULL pointer which it
gets after successful NULL pointer dereferencing on s390.

Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/block/dasd.c

index f3099c8cc143b0f3a7cd1624cae5d20e8323cf70..6fb3fd5efc11a2f777245255820021b269481cc3 100644 (file)
@@ -3601,10 +3601,11 @@ int dasd_generic_set_offline(struct ccw_device *cdev)
                 * empty
                 */
                /* sync blockdev and partitions */
-               rc = fsync_bdev(device->block->bdev);
-               if (rc != 0)
-                       goto interrupted;
-
+               if (device->block) {
+                       rc = fsync_bdev(device->block->bdev);
+                       if (rc != 0)
+                               goto interrupted;
+               }
                /* schedule device tasklet and wait for completion */
                dasd_schedule_device_bh(device);
                rc = wait_event_interruptible(shutdown_waitq,