[PATCH v1 01/25] j1939: socket: reduce the scope of addr in j1939_sk_sendmsg

[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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
index 9d3da573c31d..5e2b5aa9ceff 100644
--- a/net/can/j1939/socket.c
+++ b/net/can/j1939/socket.c
@@ -713,7 +713,6 @@ static int j1939_sk_sendmsg(struct socket *sock, struct msghdr *msg,
 {
 	struct sock *sk = sock->sk;
 	struct j1939_sock *jsk = j1939_sk(sk);
-	struct sockaddr_can *addr = msg->msg_name;
 	struct j1939_priv *priv;
 	struct net_device *ndev;
 	int ifindex;
@@ -731,6 +730,8 @@ static int j1939_sk_sendmsg(struct socket *sock, struct msghdr *msg,
 
 	/* deal with provided address info */
 	if (msg->msg_name) {
+		struct sockaddr_can *addr = msg->msg_name;
+
 		if (msg->msg_namelen < J1939_MIN_NAMELEN)
 			return -EINVAL;
 		if (addr->can_family != AF_CAN)
@@ -738,8 +739,7 @@ static int j1939_sk_sendmsg(struct socket *sock, struct msghdr *msg,
 		if (j1939_pgn_is_valid(addr->can_addr.j1939.pgn) &&
 		    !j1939_pgn_is_clean_pdu(addr->can_addr.j1939.pgn))
 			return -EINVAL;
-		/* TODO: always check if ifindex is correct? */
-		if (addr->can_ifindex && ifindex != addr->can_ifindex)
+		if (addr->can_ifindex && addr->can_ifindex != ifindex)
 			return -EBADFD;
 	}
 
-- 
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