nullb: fix error return code in null_init()
authorWei Yongjun <weiyongjun1@huawei.com>
Tue, 17 Oct 2017 12:11:46 +0000 (12:11 +0000)
committerJens Axboe <axboe@kernel.dk>
Tue, 17 Oct 2017 14:25:06 +0000 (08:25 -0600)
Fix to return error code -ENOMEM from the null_alloc_dev() error
handling case instead of 0, as done elsewhere in this function.

Fixes: 2984c8684f96 ("nullb: factor disk parameters")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/null_blk.c

index bf2c8ca3242aa60749ea03483892526de02a0389..50c83c4b2ea02ea57b11f931dc2088b771805250 100644 (file)
@@ -1991,8 +1991,10 @@ static int __init null_init(void)
 
        for (i = 0; i < nr_devices; i++) {
                dev = null_alloc_dev();
-               if (!dev)
+               if (!dev) {
+                       ret = -ENOMEM;
                        goto err_dev;
+               }
                ret = null_add_dev(dev);
                if (ret) {
                        null_free_dev(dev);