From patchwork Wed Nov 8 16:15:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 10048755 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 26FEA603FA for ; Wed, 8 Nov 2017 16:16:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AD8E2A6EC for ; Wed, 8 Nov 2017 16:16:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F5C12A6EF; Wed, 8 Nov 2017 16:16:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 976392A66B for ; Wed, 8 Nov 2017 16:16:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751856AbdKHQQP (ORCPT ); Wed, 8 Nov 2017 11:16:15 -0500 Received: from mout.web.de ([212.227.17.12]:56900 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751763AbdKHQQN (ORCPT ); Wed, 8 Nov 2017 11:16:13 -0500 Received: from [192.168.1.3] ([77.181.94.27]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0M7snk-1f7szz2sGe-00vMeW; Wed, 08 Nov 2017 17:16:03 +0100 To: linux-wpan@vger.kernel.org, netdev@vger.kernel.org, Alexander Aring , "David S. Miller" , Stefan Schmidt Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Subject: [PATCH] nl802154: Improve unlocking of a table in four functions Message-ID: Date: Wed, 8 Nov 2017 17:15:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:AwqeyFf/phHdRU9LzqRN/gisWBDDMnWxpdlpRbO4mutnKJc6ItX KO2lkdaa4vmfX+SbPdu7D9ejs6S9A0HYEUJrMUO2sHMKPLvxYHIt/2QW5aihilYY6ntrzq3 nRJ5fQLX1htP9Ih8iCIsXKvHJo7UCQIIkcLsVLalRguZ8I7GN+wNzDq0y9TgRmapE1nIn2O aB9P3tpF7tag7K3mMejYg== X-UI-Out-Filterresults: notjunk:1; V01:K0:IScdM7JdmL8=:3UiaAx/Sl5F1wYehAlWJgL Z3hVlzAervdliLtxmCiuq4khBB3J7llYwqKxEwO7lSSj6NcYRAgb+MCXBL0lIRL3GlQSkB1u8 qJy2FBrD6axkMpik9jkx3MeK35qAgOpC9pwUOlbSCvfuWS1zrO01CaYlEWR4NSrr2XmXAgK0P QW6t7PxExoB6yov+9sA4QBEN+0x1f2Z1gAQTrDQphtHilhbHhT8lsdnvSaye8I6Myiop2GxpF gLq6vkRqU58ZiQ7OLNW/RgI58YnrR4sYZLoBQQ4+o0fBLeXuB1Zehtr97i3RJKBcK05/+Vnga HExbNFkcD2H5s1bptY+V3+N1cMhtlNh/m0/jl1iWeZbM0wEzwoc1Go3QFU2SbuoraUH5/n0ot TRQpjLkl6UkEIBSizseOserLuiLFOAP5kGew6fCMhOar7aCHs6PsF7X9zbFYvki6xLWw5fD2Z BKBRNf9DTEDLjr2xmW61cA6+it3Rh56h22zMMemcAW6C07LZSOuHYNwMmBwjBPCQLRgyDEm/s i5E4Wu66nZHBB3l79ZJWdasAhI/4k+A50Ws09kVnQ91TsFJZoLGuluYt3o1+BtXw1RDF4w6XX JlhiYmwLUu3xkpXCbjCl8oeNhNKP4iO/oFNABzo5dA7icoo7QovOGpn/w9ylf5Q3UcuypRghC oxyqWxDYWEcivRr1VLigJypnWLW4RgporQ48iyrbmBceZ5X5oCxbwtrdqbN6FafPUEKrer+oE xyJmh2DnJvOZjHplPovZuNvfJVEwI3ZD14JeFGbKf4y294bFPE/LupSptajYwVtpn9tVp+PZy N3a39yHyfPshTgLt+DHmBKo0CZ1BZArJSOh5/SwxzulOjBMuG0= Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring 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 --- 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);