s390/dcssblk: fix device size calculation in dcssblk_direct_access()
authorGerald Schaefer <gerald.schaefer@de.ibm.com>
Mon, 30 Jan 2017 14:52:14 +0000 (15:52 +0100)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Fri, 3 Feb 2017 12:50:17 +0000 (13:50 +0100)
Since commit dd22f551 "block: Change direct_access calling convention",
the device size calculation in dcssblk_direct_access() is off-by-one.
This results in bdev_direct_access() always returning -ENXIO because the
returned value is not page aligned.

Fix this by adding 1 to the dev_sz calculation.

Fixes: dd22f551 ("block: Change direct_access calling convention")
Cc: <stable@vger.kernel.org> # 4.0+
Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/block/dcssblk.c

index 9d66b4fb174b80231a98737bf3f9fafeb4849c66..415d10a67b7a749366f6624d871e2c358d7fcea1 100644 (file)
@@ -892,7 +892,7 @@ dcssblk_direct_access (struct block_device *bdev, sector_t secnum,
        dev_info = bdev->bd_disk->private_data;
        if (!dev_info)
                return -ENODEV;
-       dev_sz = dev_info->end - dev_info->start;
+       dev_sz = dev_info->end - dev_info->start + 1;
        offset = secnum * 512;
        *kaddr = (void *) dev_info->start + offset;
        *pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), PFN_DEV);