We only want to receive the package if src_name name packet's dest_name is set and they are equal. If one name is missing we compare the addresses instead (else branch). Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx> --- net/can/j1939/socket.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c index 73ac92163373..9d3da573c31d 100644 --- a/net/can/j1939/socket.c +++ b/net/can/j1939/socket.c @@ -134,9 +134,8 @@ static void j1939_sk_recv_one(struct j1939_sock *jsk, struct sk_buff *oskb) /* this socket does not take packets from this iface */ return; if (!(jsk->state & J1939_SOCK_PROMISC)) { - if (jsk->addr.src_name) { - if (oskcb->addr.dst_name && - oskcb->addr.dst_name != jsk->addr.src_name) + if (jsk->addr.src_name && oskcb->addr.dst_name) { + if (oskcb->addr.dst_name != jsk->addr.src_name) return; } else { if (j1939_address_is_unicast(oskcb->addr.da) && -- 2.20.1