lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 28 Oct 2017 22:00:33 +0200
From:   SF Markus Elfring <elfring@...rs.sourceforge.net>
To:     netdev@...r.kernel.org, Andrew Lunn <andrew@...n.ch>,
        "David S. Miller" <davem@...emloft.net>,
        Florian Fainelli <f.fainelli@...il.com>,
        Russell King <rmk+kernel@....linux.org.uk>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: [PATCH] phylink: Use common error handling code in phylink_create()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Sat, 28 Oct 2017 21:48:31 +0200

* Add a jump target so that a bit of exception handling can be better
  reused at the end of this function.

* Adjust three condition checks.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/net/phy/phylink.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index bcb4755bcd95..67b19c13f405 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -533,26 +533,24 @@ struct phylink *phylink_create(struct net_device *ndev, struct device_node *np,
 	phylink_validate(pl, pl->supported, &pl->link_config);
 
 	ret = phylink_parse_mode(pl, np);
-	if (ret < 0) {
-		kfree(pl);
-		return ERR_PTR(ret);
-	}
+	if (ret)
+		goto free_link;
 
 	if (pl->link_an_mode == MLO_AN_FIXED) {
 		ret = phylink_parse_fixedlink(pl, np);
-		if (ret < 0) {
-			kfree(pl);
-			return ERR_PTR(ret);
-		}
+		if (ret)
+			goto free_link;
 	}
 
 	ret = phylink_register_sfp(pl, np);
-	if (ret < 0) {
-		kfree(pl);
-		return ERR_PTR(ret);
-	}
+	if (ret)
+		goto free_link;
 
 	return pl;
+
+free_link:
+	kfree(pl);
+	return ERR_PTR(ret);
 }
 EXPORT_SYMBOL_GPL(phylink_create);
 
-- 
2.14.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ