[PATCH v1 18/34] j1939: j1939_sk_bind(): reduce unneeded reference counting a bit

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

 



Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
---
 net/can/j1939/socket.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
index 49c2d3601ca0..a94e36d54c2d 100644
--- a/net/can/j1939/socket.c
+++ b/net/can/j1939/socket.c
@@ -392,6 +392,7 @@ static int j1939_sk_bind(struct socket *sock, struct sockaddr *uaddr, int len)
 		/* drop old references */
 		priv = j1939_priv_get_by_ndev(ndev);
 		j1939_local_ecu_put(priv, jsk->addr.src_name, jsk->addr.sa);
+		j1939_priv_put(priv);
 	} else {
 		if (ndev->type != ARPHRD_CAN) {
 			ret = -ENODEV;
@@ -405,7 +406,6 @@ static int j1939_sk_bind(struct socket *sock, struct sockaddr *uaddr, int len)
 		}
 
 		jsk->ifindex = addr->can_ifindex;
-		j1939_priv_get(priv);
 	}
 
 	/* set default transmit pgn */
@@ -418,7 +418,7 @@ static int j1939_sk_bind(struct socket *sock, struct sockaddr *uaddr, int len)
 	ret = j1939_local_ecu_get(priv, jsk->addr.src_name, jsk->addr.sa);
 	if (ret) {
 		j1939_netdev_stop(ndev);
-		goto out_priv_put;
+		goto out_dev_put;
 	}
 
 	if (!(jsk->state & J1939_SOCK_BOUND)) {
@@ -429,9 +429,7 @@ static int j1939_sk_bind(struct socket *sock, struct sockaddr *uaddr, int len)
 		jsk->state |= J1939_SOCK_BOUND;
 	}
 
- out_priv_put:	/* fallthrough */
-	j1939_priv_put(priv);
- out_dev_put:
+ out_dev_put: /* fallthrough */
 	dev_put(ndev);
  out_release_sock:
 	release_sock(sock->sk);
-- 
2.20.1




[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux