summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Hartkopp <socketcan@hartkopp.net>2023-06-07 09:27:08 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-07-05 18:25:05 +0100
commitd874cf9799a973d58b86b2973392e0111260b87a (patch)
tree32bc7bf75e1fdb1f7f0ee6a9c0c5a836e99520f3
parent27d03d15bb8baccb1453ad4d104fd92cabaac33f (diff)
downloadlinux-d874cf9799a973d58b86b2973392e0111260b87a.tar.gz
linux-d874cf9799a973d58b86b2973392e0111260b87a.tar.bz2
linux-d874cf9799a973d58b86b2973392e0111260b87a.zip
can: isotp: isotp_sendmsg(): fix return error fix on TX path
commit e38910c0072b541a91954682c8b074a93e57c09b upstream. With commit d674a8f123b4 ("can: isotp: isotp_sendmsg(): fix return error on FC timeout on TX path") the missing correct return value in the case of a protocol error was introduced. But the way the error value has been read and sent to the user space does not follow the common scheme to clear the error after reading which is provided by the sock_error() function. This leads to an error report at the following write() attempt although everything should be working. Fixes: d674a8f123b4 ("can: isotp: isotp_sendmsg(): fix return error on FC timeout on TX path") Reported-by: Carsten Schmidt <carsten.schmidt-achim@t-online.de> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Link: https://lore.kernel.org/all/20230607072708.38809-1-socketcan@hartkopp.net Cc: stable@vger.kernel.org Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--net/can/isotp.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/net/can/isotp.c b/net/can/isotp.c
index ca69ca39c8fd..4dccf7b4b88d 100644
--- a/net/can/isotp.c
+++ b/net/can/isotp.c
@@ -992,8 +992,9 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
/* wait for complete transmission of current pdu */
wait_event_interruptible(so->wait, so->tx.state == ISOTP_IDLE);
- if (sk->sk_err)
- return -sk->sk_err;
+ err = sock_error(sk);
+ if (err)
+ return err;
}
return size;