* [PATCH] phylink: Use common error handling code in phylink_create()
@ 2017-10-28 20:00 SF Markus Elfring
2017-10-28 21:08 ` Florian Fainelli
2017-10-28 21:24 ` Russell King - ARM Linux
0 siblings, 2 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-10-28 20:00 UTC (permalink / raw)
To: netdev, Andrew Lunn, David S. Miller, Florian Fainelli, Russell King
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.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@users.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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] phylink: Use common error handling code in phylink_create()
2017-10-28 20:00 [PATCH] phylink: Use common error handling code in phylink_create() SF Markus Elfring
@ 2017-10-28 21:08 ` Florian Fainelli
2017-10-28 21:24 ` Russell King - ARM Linux
1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2017-10-28 21:08 UTC (permalink / raw)
To: SF Markus Elfring, netdev, Andrew Lunn, David S. Miller, Russell King
Cc: LKML, kernel-janitors
On 10/28/2017 01:00 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.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@users.sourceforge.net>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] phylink: Use common error handling code in phylink_create()
2017-10-28 20:00 [PATCH] phylink: Use common error handling code in phylink_create() SF Markus Elfring
2017-10-28 21:08 ` Florian Fainelli
@ 2017-10-28 21:24 ` Russell King - ARM Linux
1 sibling, 0 replies; 3+ messages in thread
From: Russell King - ARM Linux @ 2017-10-28 21:24 UTC (permalink / raw)
To: SF Markus Elfring
Cc: netdev, Andrew Lunn, David S. Miller, Florian Fainelli, LKML,
kernel-janitors
On Sat, Oct 28, 2017 at 10:00:33PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.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@users.sourceforge.net>
Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
Thanks.
> ---
> 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
>
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-10-28 21:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-28 20:00 [PATCH] phylink: Use common error handling code in phylink_create() SF Markus Elfring
2017-10-28 21:08 ` Florian Fainelli
2017-10-28 21:24 ` Russell King - ARM Linux
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).