]> git.hungrycats.org Git - linux/commit
null_blk: Fix return value of nullb_device_power_store()
authorDamien Le Moal <dlemoal@kernel.org>
Mon, 27 May 2024 04:34:45 +0000 (13:34 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 22 Nov 2024 14:37:35 +0000 (15:37 +0100)
commit777595da53aa11e7e2fa0332a2c4b0511086be39
tree168f0ccfdbeda2a6b43de47086b102d9e34e6617
parent1d4c8baef435c98e8d5aa7027dc5a9f70834ba16
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 <dlemoal@kernel.org>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Link: https://lore.kernel.org/r/20240527043445.235267-1-dlemoal@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/block/null_blk/main.c