Skip to contentSkip to conversation

nbd: fix return value in error handling path

PATCH Applied Gustavo A. R. Silva 4 participants 4 messages Feb 12, 2018 – Feb 27, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 drivers/block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/nbd.c +1 -1
index 5f2a424..86258b0 100644
@@ -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);
 		}
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Gustavo A. R. Silva

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")
Quoted 21 lines
---
 drivers/block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/nbd.c +1 -1
index 5f2a424..86258b0 100644
@@ -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);
 		}
Signature · 1 line
2.7.4
#2 lore raw
Quoted 7 lines · Omar Sandoval
Quoted 5 lines · Gustavo A. R. Silva

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")

Thanks, Omar.
--
Gustavo

Quoted 21 lines
Quoted 21 lines
---
  drivers/block/nbd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/nbd.c +1 -1
index 5f2a424..86258b0 100644
@@ -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);
  		}
Signature · 1 line
2.7.4
maintainer Applied
#3 lore raw
In reply to Gustavo A. R. Silva
Quoted 2 lines · Gustavo A. R. Silva

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.

Signature · 1 line
Jens Axboe