Skip to content

Commit 777595d

Browse files
damien-lemoalgregkh
authored andcommitted
null_blk: Fix return value of nullb_device_power_store()
commit d9ff882b54f99f96787fa3df7cd938966843c418 upstream. When powering on a null_blk device that is not already on, the return value ret that is initialized to be count is reused to check the return value of null_add_dev(), leading to nullb_device_power_store() to return null_add_dev() return value (0 on success) instead of "count". So make sure to set ret to be equal to count when there are no errors. Fixes: a2db328b0839 ("null_blk: fix null-ptr-dereference while configuring 'power' and 'submit_queues'") Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Yu Kuai <[email protected]> Reviewed-by: Kanchan Joshi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Xiangyu Chen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1d4c8ba commit 777595d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/block/null_blk/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ static ssize_t nullb_device_power_store(struct config_item *item,
470470

471471
set_bit(NULLB_DEV_FL_CONFIGURED, &dev->flags);
472472
dev->power = newp;
473+
ret = count;
473474
} else if (dev->power && !newp) {
474475
if (test_and_clear_bit(NULLB_DEV_FL_UP, &dev->flags)) {
475476
dev->power = newp;

0 commit comments

Comments
 (0)