Commit a75110c3 authored by Chaitanya Kulkarni's avatar Chaitanya Kulkarni Committed by Jens Axboe

null_blk: fix return value from null_add_dev()

The function nullb_device_power_store() returns -ENOMEM when
null_add_dev() fails. null_add_dev() can fail with return value
other than -ENOMEM such as -EINVAL when Zoned Block Device option
is used, see :

nullb_device_power_store()
 null_add_dev()
  null_init_zoned_dev()
	return -EINVAL;

When trying to load the module having -ENOMEM value returned on the
command line creates confusion when pleanty of memory is free on the
machine.

Instead of hardcoding -ENOMEM return the value of null_add_dev()
function.
Signed-off-by: default avatarChaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20220215115951.15945-1-kch@nvidia.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent d9a74051
...@@ -431,9 +431,10 @@ static ssize_t nullb_device_power_store(struct config_item *item, ...@@ -431,9 +431,10 @@ static ssize_t nullb_device_power_store(struct config_item *item,
if (!dev->power && newp) { if (!dev->power && newp) {
if (test_and_set_bit(NULLB_DEV_FL_UP, &dev->flags)) if (test_and_set_bit(NULLB_DEV_FL_UP, &dev->flags))
return count; return count;
if (null_add_dev(dev)) { ret = null_add_dev(dev);
if (ret) {
clear_bit(NULLB_DEV_FL_UP, &dev->flags); clear_bit(NULLB_DEV_FL_UP, &dev->flags);
return -ENOMEM; return ret;
} }
set_bit(NULLB_DEV_FL_CONFIGURED, &dev->flags); set_bit(NULLB_DEV_FL_CONFIGURED, &dev->flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment