From: Jan Höppner Date: Thu, 22 Jun 2017 15:17:15 +0000 (+0200) Subject: s390/dasd: Fix faulty ENODEV for RO sysfs attribute X-Git-Tag: v4.13-rc1~192^2~1 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=795c9a5106119f45d2501c4fb01051178904753f;p=karo-tx-linux.git s390/dasd: Fix faulty ENODEV for RO sysfs attribute If a device is offline it can still be set to read-only via the bus id through sysfs. Only the read-only feature flag for the ccw_device is then set. If the device is online the corresponding block device needs to be set to read-only as well (via set_disk_ro()). The check whether there is a device to do so, however, happens after the feature flag was set. This leads to an unnecessary "no such device" error in the offline case. This bug was introduced by commit 7571cb1c8e3cc ("s390/dasd: Make use of dasd_set_feature() more often"). Fix this by simply returning count if no device is available. Fixes: 7571cb1c8e3cc ("s390/dasd: Make use of dasd_set_feature() more often") Reviewed-by: Stefan Haberland Signed-off-by: Jan Höppner Signed-off-by: Martin Schwidefsky --- diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c index e943d9c48926..7c7351276d2e 100644 --- a/drivers/s390/block/dasd_devmap.c +++ b/drivers/s390/block/dasd_devmap.c @@ -786,7 +786,7 @@ dasd_ro_store(struct device *dev, struct device_attribute *attr, device = dasd_device_from_cdev(cdev); if (IS_ERR(device)) - return PTR_ERR(device); + return count; spin_lock_irqsave(get_ccwdev_lock(cdev), flags); val = val || test_bit(DASD_FLAG_DEVICE_RO, &device->flags);