can: isotp: isotp_sendmsg(): fix return error fix on TX path
authorOliver Hartkopp <socketcan@hartkopp.net>
Wed, 7 Jun 2023 07:27:08 +0000 (09:27 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Thu, 22 Jun 2023 08:45:09 +0000 (10:45 +0200)
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>
net/can/isotp.c

index 84f9aba..ca9d728 100644 (file)
@@ -1112,8 +1112,9 @@ wait_free_buffer:
                if (err)
                        goto err_event_drop;
 
-               if (sk->sk_err)
-                       return -sk->sk_err;
+               err = sock_error(sk);
+               if (err)
+                       return err;
        }
 
        return size;