Skip to content

Commit

Permalink
null_blk: Fix return value of nullb_device_power_store()
Browse files Browse the repository at this point in the history
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: a2db328 ("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]>
  • Loading branch information
damien-lemoal authored and axboe committed May 27, 2024
1 parent c8c1f70 commit d9ff882
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/block/null_blk/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ static ssize_t nullb_device_power_store(struct config_item *item,

set_bit(NULLB_DEV_FL_CONFIGURED, &dev->flags);
dev->power = newp;
ret = count;
} else if (dev->power && !newp) {
if (test_and_clear_bit(NULLB_DEV_FL_UP, &dev->flags)) {
dev->power = newp;
Expand Down

0 comments on commit d9ff882

Please sign in to comment.