From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C48315AE0 for ; Tue, 25 Jul 2023 11:11:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2195C433C8; Tue, 25 Jul 2023 11:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1690283517; bh=Hfu3E/HExCBaVoV9H4zCCTGuD5VfAquPL/geKOhyjV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=anhxwf7uFWu54/EmR3sxdPJin32CA8Ajo16idSoqxbEesTzEQ5KdbevN17nh5GsBD 2w4vnD72Ru7b6o6khQ4pxQnDa8BkeY7pMurlDejSnboXsC0BzhPtjPPscNUrS8VqaA jnHLOHmlmtuLLVI9TKl3hnnv6a4usuHftqGNrf8I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Carsten Schmidt , Oliver Hartkopp , Marc Kleine-Budde Subject: [PATCH 5.10 003/509] can: isotp: isotp_sendmsg(): fix return error fix on TX path Date: Tue, 25 Jul 2023 12:39:02 +0200 Message-ID: <20230725104553.765297422@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725104553.588743331@linuxfoundation.org> References: <20230725104553.588743331@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Oliver Hartkopp 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 Signed-off-by: Oliver Hartkopp Link: https://lore.kernel.org/all/20230607072708.38809-1-socketcan@hartkopp.net Cc: stable@vger.kernel.org Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- net/can/isotp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/net/can/isotp.c +++ b/net/can/isotp.c @@ -990,8 +990,9 @@ static int isotp_sendmsg(struct socket * /* 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;