[PATCH] nl802154: Improve unlocking of a table in four functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 8 Nov 2017 17:08:55 +0100

* Add jump targets so that a call of the function "rdev_unlock_llsec_table"
  is stored only once in these function implementations.

* Replace four calls by goto statements.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
 net/ieee802154/nl802154.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index 99f6c254ea77..33865d355433 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -1527,16 +1527,16 @@ nl802154_dump_llsec_key(struct sk_buff *skb, struct netlink_callback *cb)
 				      rdev, wpan_dev->netdev, key) < 0) {
 			/* TODO */
 			err = -EIO;
-			rdev_unlock_llsec_table(rdev, wpan_dev);
-			goto out_err;
+			goto unlock_table;
 		}
 	}
 
 	cb->args[2] = 1;
 
 out:
-	rdev_unlock_llsec_table(rdev, wpan_dev);
 	err = skb->len;
+unlock_table:
+	rdev_unlock_llsec_table(rdev, wpan_dev);
 out_err:
 	nl802154_finish_wpan_dev_dump(rdev);
 
@@ -1697,16 +1697,16 @@ nl802154_dump_llsec_dev(struct sk_buff *skb, struct netlink_callback *cb)
 					 rdev, wpan_dev->netdev, dev) < 0) {
 			/* TODO */
 			err = -EIO;
-			rdev_unlock_llsec_table(rdev, wpan_dev);
-			goto out_err;
+			goto unlock_table;
 		}
 	}
 
 	cb->args[2] = 1;
 
 out:
-	rdev_unlock_llsec_table(rdev, wpan_dev);
 	err = skb->len;
+unlock_table:
+	rdev_unlock_llsec_table(rdev, wpan_dev);
 out_err:
 	nl802154_finish_wpan_dev_dump(rdev);
 
@@ -1875,8 +1875,7 @@ nl802154_dump_llsec_devkey(struct sk_buff *skb, struct netlink_callback *cb)
 						 kpos) < 0) {
 				/* TODO */
 				err = -EIO;
-				rdev_unlock_llsec_table(rdev, wpan_dev);
-				goto out_err;
+				goto unlock_table;
 			}
 		}
 	}
@@ -1884,8 +1883,9 @@ nl802154_dump_llsec_devkey(struct sk_buff *skb, struct netlink_callback *cb)
 	cb->args[2] = 1;
 
 out:
-	rdev_unlock_llsec_table(rdev, wpan_dev);
 	err = skb->len;
+unlock_table:
+	rdev_unlock_llsec_table(rdev, wpan_dev);
 out_err:
 	nl802154_finish_wpan_dev_dump(rdev);
 
@@ -2034,16 +2034,16 @@ nl802154_dump_llsec_seclevel(struct sk_buff *skb, struct netlink_callback *cb)
 					   rdev, wpan_dev->netdev, sl) < 0) {
 			/* TODO */
 			err = -EIO;
-			rdev_unlock_llsec_table(rdev, wpan_dev);
-			goto out_err;
+			goto unlock_table;
 		}
 	}
 
 	cb->args[2] = 1;
 
 out:
-	rdev_unlock_llsec_table(rdev, wpan_dev);
 	err = skb->len;
+unlock_table:
+	rdev_unlock_llsec_table(rdev, wpan_dev);
 out_err:
 	nl802154_finish_wpan_dev_dump(rdev);
 
-- 
2.15.0

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux