linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/decnet: fix -EFAULT error that is not getting returned
@ 2019-12-04 15:11 Colin King
  2019-12-04 17:39 ` Eric Dumazet
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2019-12-04 15:11 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, linux-decnet-user, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently an -EFAULT error on a memcpy_to_msg is not being returned
because it is being overwritten when variable rv is being re-assigned
to the number of bytes copied after breaking out of a loop. Fix this
by instead assigning the error to variable copied so that this error
code propegated to rv and hence is returned at the end of the function.

[ This bug was was introduced before the current git history ]

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 net/decnet/af_decnet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index e19a92a62e14..e23d9f219597 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -1759,7 +1759,7 @@ static int dn_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
 			chunk = size - copied;
 
 		if (memcpy_to_msg(msg, skb->data, chunk)) {
-			rv = -EFAULT;
+			copied = -EFAULT;
 			break;
 		}
 		copied += chunk;
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net/decnet: fix -EFAULT error that is not getting returned
  2019-12-04 15:11 [PATCH] net/decnet: fix -EFAULT error that is not getting returned Colin King
@ 2019-12-04 17:39 ` Eric Dumazet
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2019-12-04 17:39 UTC (permalink / raw)
  To: Colin King, David S . Miller, Eric Dumazet, linux-decnet-user, netdev
  Cc: kernel-janitors, linux-kernel



On 12/4/19 7:11 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently an -EFAULT error on a memcpy_to_msg is not being returned
> because it is being overwritten when variable rv is being re-assigned
> to the number of bytes copied after breaking out of a loop. Fix this
> by instead assigning the error to variable copied so that this error
> code propegated to rv and hence is returned at the end of the function.
> 
> [ This bug was was introduced before the current git history ]
> 
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  net/decnet/af_decnet.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
> index e19a92a62e14..e23d9f219597 100644
> --- a/net/decnet/af_decnet.c
> +++ b/net/decnet/af_decnet.c
> @@ -1759,7 +1759,7 @@ static int dn_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
>  			chunk = size - copied;
>  
>  		if (memcpy_to_msg(msg, skb->data, chunk)) {
> -			rv = -EFAULT;
> +			copied = -EFAULT;

This does not look right.

We probably want :
		if (!copied)
			copied = -EFAULT;

>  			break;
>  		}
>  		copied += chunk;
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-04 17:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-04 15:11 [PATCH] net/decnet: fix -EFAULT error that is not getting returned Colin King
2019-12-04 17:39 ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).