2018-02-12 17:42:31

by Gustavo A. R. Silva

[permalink] [raw]
Subject: [PATCH] nbd: fix return value in error handling path

It seems that the proper value to return in this particular case is the
one contained into variable new_index instead of ret.

Addresses-Coverity-ID: 1465148 ("Copy-paste error")
Fixes: e46c7287b1c2 ("nbd: add a basic netlink interface")
Signed-off-by: Gustavo A. R. Silva <[email protected]>
---
drivers/block/nbd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 5f2a424..86258b0 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1591,7 +1591,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
if (new_index < 0) {
mutex_unlock(&nbd_index_mutex);
printk(KERN_ERR "nbd: failed to add new device\n");
- return ret;
+ return new_index;
}
nbd = idr_find(&nbd_index_idr, new_index);
}
--
2.7.4



2018-02-26 23:03:05

by Omar Sandoval

[permalink] [raw]
Subject: Re: [PATCH] nbd: fix return value in error handling path

On Mon, Feb 12, 2018 at 11:14:55AM -0600, Gustavo A. R. Silva wrote:
> It seems that the proper value to return in this particular case is the
> one contained into variable new_index instead of ret.
>
> Addresses-Coverity-ID: 1465148 ("Copy-paste error")
> Fixes: e46c7287b1c2 ("nbd: add a basic netlink interface")

Reviewed-by: Omar Sandoval <[email protected]>

> Signed-off-by: Gustavo A. R. Silva <[email protected]>
> ---
> drivers/block/nbd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 5f2a424..86258b0 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -1591,7 +1591,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
> if (new_index < 0) {
> mutex_unlock(&nbd_index_mutex);
> printk(KERN_ERR "nbd: failed to add new device\n");
> - return ret;
> + return new_index;
> }
> nbd = idr_find(&nbd_index_idr, new_index);
> }
> --
> 2.7.4
>

2018-02-27 22:53:13

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH] nbd: fix return value in error handling path

On 2/12/18 10:14 AM, Gustavo A. R. Silva wrote:
> It seems that the proper value to return in this particular case is the
> one contained into variable new_index instead of ret.

Thanks, applied.

--
Jens Axboe


2018-02-27 23:06:07

by Gustavo A. R. Silva

[permalink] [raw]
Subject: Re: [PATCH] nbd: fix return value in error handling path



On 02/26/2018 05:01 PM, Omar Sandoval wrote:
> On Mon, Feb 12, 2018 at 11:14:55AM -0600, Gustavo A. R. Silva wrote:
>> It seems that the proper value to return in this particular case is the
>> one contained into variable new_index instead of ret.
>>
>> Addresses-Coverity-ID: 1465148 ("Copy-paste error")
>> Fixes: e46c7287b1c2 ("nbd: add a basic netlink interface")
> Reviewed-by: Omar Sandoval <[email protected]>

Thanks, Omar.
--
Gustavo

>> Signed-off-by: Gustavo A. R. Silva <[email protected]>
>> ---
>> drivers/block/nbd.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
>> index 5f2a424..86258b0 100644
>> --- a/drivers/block/nbd.c
>> +++ b/drivers/block/nbd.c
>> @@ -1591,7 +1591,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
>> if (new_index < 0) {
>> mutex_unlock(&nbd_index_mutex);
>> printk(KERN_ERR "nbd: failed to add new device\n");
>> - return ret;
>> + return new_index;
>> }
>> nbd = idr_find(&nbd_index_idr, new_index);
>> }
>> --
>> 2.7.4
>>