When reading from an unbound can-isotp socket the syscall blocked indefinitely. As unbound sockets (without given CAN address information) do not make sense anyway we directly return -EADDRNOTAVAIL on read() analogue to the known behavior from sendmsg(). Fixes: e057dd3fc20f ("can: add ISO 15765-2:2016 transport protocol") Link: https://github.com/linux-can/can-utils/issues/349 Suggested-by: Derek Will <derekrobertwill@xxxxxxxxx> Signed-off-by: Oliver Hartkopp <socketcan@xxxxxxxxxxxx> --- net/can/isotp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/can/isotp.c b/net/can/isotp.c index 1662103ce125..6b6c82206c30 100644 --- a/net/can/isotp.c +++ b/net/can/isotp.c @@ -1044,16 +1044,20 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) static int isotp_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, int flags) { struct sock *sk = sock->sk; struct sk_buff *skb; + struct isotp_sock *so = isotp_sk(sk); int err = 0; int noblock; noblock = flags & MSG_DONTWAIT; flags &= ~MSG_DONTWAIT; + if (!so->bound) + return -EADDRNOTAVAIL; + skb = skb_recv_datagram(sk, flags, noblock, &err); if (!skb) return err; if (size < skb->len) -- 2.30.2