Skip to content

Commit d9ff882

Browse files
damien-lemoalaxboe
authored andcommitted
null_blk: Fix return value of nullb_device_power_store()
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]>
1 parent c8c1f70 commit d9ff882

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
@@ -494,6 +494,7 @@ static ssize_t nullb_device_power_store(struct config_item *item,
494494

495495
set_bit(NULLB_DEV_FL_CONFIGURED, &dev->flags);
496496
dev->power = newp;
497+
ret = count;
497498
} else if (dev->power && !newp) {
498499
if (test_and_clear_bit(NULLB_DEV_FL_UP, &dev->flags)) {
499500
dev->power = newp;

0 commit comments

Comments
 (0)