diff mbox series

[v2] can: Use common error handling code in vxcan_newlink()

Message ID 23fbbdba-fb11-a6bc-7d6a-4af43ef79503@users.sourceforge.net
State Rejected, archived
Delegated to: David Miller
Headers show
Series [v2] can: Use common error handling code in vxcan_newlink() | expand

Commit Message

SF Markus Elfring Nov. 1, 2017, 2:16 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 1 Nov 2017 14:56:15 +0100

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

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
An approach to make two checks for a failure predicate a bit safer
was rejected on 2017-10-28.
The possibility remains to reconsider such an adjustment later again.
https://lkml.org/lkml/2017/10/28/125
https://lkml.kernel.org/r/<264b3c2b-8354-5769-639c-ac8d2fcbe630@hartkopp.net>

 drivers/net/can/vxcan.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Oliver Hartkopp Nov. 1, 2017, 7:09 p.m. UTC | #1
On 11/01/2017 03:16 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 1 Nov 2017 14:56:15 +0100
> 
> Add a jump target so that a bit of exception handling can be better reused
> at the end of this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>

Again: Posting such a patch on linux-can@vger.kernel.org is ENOUGH!

No need to cross post such a patch additionally on

netdev@vger.kernel.org
linux-kernel@vger.kernel.org
kernel-janitors@vger.kernel.org

and to each of the maintainers

mkl@pengutronix.de
wg@grandegger.com
socketcan@hartkopp.net

We all subscribed the mailing list and listen to it.
That's the intention of a mailing list ...

Cross posting is not appreciated in the community.

Thanks,
Oliver

> ---
> 
> v2:
> An approach to make two checks for a failure predicate a bit safer
> was rejected on 2017-10-28.
> The possibility remains to reconsider such an adjustment later again.
> https://lkml.org/lkml/2017/10/28/125
> https://lkml.kernel.org/r/<264b3c2b-8354-5769-639c-ac8d2fcbe630@hartkopp.net>
> 
>   drivers/net/can/vxcan.c | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/can/vxcan.c b/drivers/net/can/vxcan.c
> index 8404e8852a0f..5d1753cfacea 100644
> --- a/drivers/net/can/vxcan.c
> +++ b/drivers/net/can/vxcan.c
> @@ -227,10 +227,8 @@ static int vxcan_newlink(struct net *net, struct net_device *dev,
>   	netif_carrier_off(peer);
>   
>   	err = rtnl_configure_link(peer, ifmp);
> -	if (err < 0) {
> -		unregister_netdevice(peer);
> -		return err;
> -	}
> +	if (err < 0)
> +		goto unregister_network_device;
>   
>   	/* register first device */
>   	if (tb[IFLA_IFNAME])
> @@ -239,10 +237,8 @@ static int vxcan_newlink(struct net *net, struct net_device *dev,
>   		snprintf(dev->name, IFNAMSIZ, DRV_NAME "%%d");
>   
>   	err = register_netdevice(dev);
> -	if (err < 0) {
> -		unregister_netdevice(peer);
> -		return err;
> -	}
> +	if (err < 0)
> +		goto unregister_network_device;
>   
>   	netif_carrier_off(dev);
>   
> @@ -254,6 +250,10 @@ static int vxcan_newlink(struct net *net, struct net_device *dev,
>   	rcu_assign_pointer(priv->peer, dev);
>   
>   	return 0;
> +
> +unregister_network_device:
> +	unregister_netdevice(peer);
> +	return err;
>   }
>   
>   static void vxcan_dellink(struct net_device *dev, struct list_head *head)
>
SF Markus Elfring Nov. 1, 2017, 7:37 p.m. UTC | #2
> Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>

Thanks for another positive feedback.


> Again: Posting such a patch on linux-can@vger.kernel.org is ENOUGH!

I was informed in an other way for Linux software patches.


> No need to cross post such a patch additionally on
> 
> netdev@vger.kernel.org
> linux-kernel@vger.kernel.org

These addresses were suggested (or recommended?) by the script “get_maintainer.pl”.


> kernel-janitors@vger.kernel.org

I tend to add this address also for my update suggestions.


> and to each of the maintainers> We all subscribed the mailing list and listen to it.

This is generally fine. - But I do not know how long such subscriptions
will be active.


> That's the intention of a mailing list ...

I know …


> Cross posting is not appreciated in the community.

How does this view fit to the information in the section “5) Select
the recipients for your patch” from the document “submitting-patches.rst”?

Regards,
Markus
Oliver Hartkopp Nov. 2, 2017, 8:22 a.m. UTC | #3
On 11/01/2017 08:37 PM, SF Markus Elfring wrote:

> These addresses were suggested (or recommended?) by the script “get_maintainer.pl”.

I know.

(..)

> How does this view fit to the information in the section “5) Select
> the recipients for your patch” from the document “submitting-patches.rst”?

We discussed and agreed about your patch. It is clear and simple and has 
no side effects to any other driver nor other subsystems.

It was just about getting *this* patch into upstream where the Linux CAN 
ML is the right place to post - that was my suggestion. So there was no 
need to take the *standard* get_maintainer mail pump-gun again for this 
patch in order to save bandwidth, energy and peoples lifetime :-)

Regards,
Oliver
Marc Kleine-Budde Nov. 7, 2017, 8:21 a.m. UTC | #4
On 11/01/2017 03:16 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 1 Nov 2017 14:56:15 +0100
> 
> Add a jump target so that a bit of exception handling can be better reused
> at the end of this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

applied to can-next.

Tnx,
Marc
diff mbox series

Patch

diff --git a/drivers/net/can/vxcan.c b/drivers/net/can/vxcan.c
index 8404e8852a0f..5d1753cfacea 100644
--- a/drivers/net/can/vxcan.c
+++ b/drivers/net/can/vxcan.c
@@ -227,10 +227,8 @@  static int vxcan_newlink(struct net *net, struct net_device *dev,
 	netif_carrier_off(peer);
 
 	err = rtnl_configure_link(peer, ifmp);
-	if (err < 0) {
-		unregister_netdevice(peer);
-		return err;
-	}
+	if (err < 0)
+		goto unregister_network_device;
 
 	/* register first device */
 	if (tb[IFLA_IFNAME])
@@ -239,10 +237,8 @@  static int vxcan_newlink(struct net *net, struct net_device *dev,
 		snprintf(dev->name, IFNAMSIZ, DRV_NAME "%%d");
 
 	err = register_netdevice(dev);
-	if (err < 0) {
-		unregister_netdevice(peer);
-		return err;
-	}
+	if (err < 0)
+		goto unregister_network_device;
 
 	netif_carrier_off(dev);
 
@@ -254,6 +250,10 @@  static int vxcan_newlink(struct net *net, struct net_device *dev,
 	rcu_assign_pointer(priv->peer, dev);
 
 	return 0;
+
+unregister_network_device:
+	unregister_netdevice(peer);
+	return err;
 }
 
 static void vxcan_dellink(struct net_device *dev, struct list_head *head)