Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx> --- net/can/j1939/socket.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c index c637fad6c805..ca85fbce7556 100644 --- a/net/can/j1939/socket.c +++ b/net/can/j1939/socket.c @@ -329,6 +329,12 @@ static int j1939_sk_connect(struct socket *sock, struct sockaddr *uaddr, goto out_release_sock; } + /* A connect() to a different interface is not supported. */ + if (jsk->ifindex != addr->can_ifindex) { + ret = -EINVAL; + goto out_release_sock; + } + jsk->addr.dst_name = addr->can_addr.j1939.name; jsk->addr.da = addr->can_addr.j1939.addr; -- 2.20.1