diff mbox series

[2/3] ublk_drv: uninitialized error code in ublk_ctrl_get_queue_affinity()

Message ID YtVAijzg2MTzfMnh@kili (mailing list archive)
State New, archived
Headers show
Series [1/3] ublk_drv: fix an IS_ERR() vs NULL check | expand

Commit Message

Dan Carpenter July 18, 2022, 11:14 a.m. UTC
Initialize the "ret" variable so we don't return uninitialized data if
ublk_get_device_from_id() fails.

Fixes: 71f28f3136af ("ublk_drv: add io_uring based userspace block driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/block/ublk_drv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Ming Lei July 18, 2022, 12:22 p.m. UTC | #1
On Mon, Jul 18, 2022 at 02:14:18PM +0300, Dan Carpenter wrote:
> Initialize the "ret" variable so we don't return uninitialized data if
> ublk_get_device_from_id() fails.
> 
> Fixes: 71f28f3136af ("ublk_drv: add io_uring based userspace block driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/block/ublk_drv.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index 97725d13e4bd..c0f9a5b4ed58 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -1298,13 +1298,12 @@ static int ublk_ctrl_get_queue_affinity(struct io_uring_cmd *cmd)
>  	struct ublk_device *ub;
>  	unsigned long queue;
>  	unsigned int retlen;
> -	int ret;
> +	int ret = -EINVAL;

This one has been fixed in for-5.20/block by "ublk_drv: fix build warning with
-Wmaybe-uninitialized and one sparse warning".


Thanks,
Ming
diff mbox series

Patch

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 97725d13e4bd..c0f9a5b4ed58 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -1298,13 +1298,12 @@  static int ublk_ctrl_get_queue_affinity(struct io_uring_cmd *cmd)
 	struct ublk_device *ub;
 	unsigned long queue;
 	unsigned int retlen;
-	int ret;
+	int ret = -EINVAL;
 
 	ub = ublk_get_device_from_id(header->dev_id);
 	if (!ub)
 		goto out;
 
-	ret = -EINVAL;
 	queue = header->data[0];
 	if (queue >= ub->dev_info.nr_hw_queues)
 		goto out;