* [PATCH] can: raw: fix getsockopt() for new CAN_RAW_XL_VCID_OPTS
@ 2024-02-19 20:00 Oliver Hartkopp
2024-02-19 20:23 ` Oliver Hartkopp
2024-02-20 7:26 ` Marc Kleine-Budde
0 siblings, 2 replies; 3+ messages in thread
From: Oliver Hartkopp @ 2024-02-19 20:00 UTC (permalink / raw)
To: linux-can; +Cc: Marc Kleine-Budde, netdev, Oliver Hartkopp, Simon Horman
The code for the CAN_RAW_XL_VCID_OPTS getsockopt() was incompletely adopted
from the CAN_RAW_FILTER getsockopt().
Add the missing put_user() and return statements.
Flagged by Smatch.
Fixes: c83c22ec1493 ("can: canxl: add virtual CAN network identifier support")
Reported-by: Simon Horman <horms@kernel.org>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
---
net/can/raw.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/can/raw.c b/net/can/raw.c
index cb8e6f788af8..897ffc17d850 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -833,11 +833,13 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,
if (len > sizeof(ro->raw_vcid_opts))
len = sizeof(ro->raw_vcid_opts);
if (copy_to_user(optval, &ro->raw_vcid_opts, len))
err = -EFAULT;
}
- break;
+ if (!err)
+ err = put_user(len, optlen);
+ return err;
case CAN_RAW_JOIN_FILTERS:
if (len > sizeof(int))
len = sizeof(int);
val = &ro->join_filters;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] can: raw: fix getsockopt() for new CAN_RAW_XL_VCID_OPTS
2024-02-19 20:00 [PATCH] can: raw: fix getsockopt() for new CAN_RAW_XL_VCID_OPTS Oliver Hartkopp
@ 2024-02-19 20:23 ` Oliver Hartkopp
2024-02-20 7:26 ` Marc Kleine-Budde
1 sibling, 0 replies; 3+ messages in thread
From: Oliver Hartkopp @ 2024-02-19 20:23 UTC (permalink / raw)
To: linux-can; +Cc: Marc Kleine-Budde, netdev, Simon Horman
Sorry. Of course it is a [PATCH net-next] where the referenced commit
has been applied.
Best regards,
Oliver
On 2024-02-19 21:00, Oliver Hartkopp wrote:
> The code for the CAN_RAW_XL_VCID_OPTS getsockopt() was incompletely adopted
> from the CAN_RAW_FILTER getsockopt().
>
> Add the missing put_user() and return statements.
>
> Flagged by Smatch.
> Fixes: c83c22ec1493 ("can: canxl: add virtual CAN network identifier support")
> Reported-by: Simon Horman <horms@kernel.org>
> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
> ---
> net/can/raw.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/can/raw.c b/net/can/raw.c
> index cb8e6f788af8..897ffc17d850 100644
> --- a/net/can/raw.c
> +++ b/net/can/raw.c
> @@ -833,11 +833,13 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,
> if (len > sizeof(ro->raw_vcid_opts))
> len = sizeof(ro->raw_vcid_opts);
> if (copy_to_user(optval, &ro->raw_vcid_opts, len))
> err = -EFAULT;
> }
> - break;
> + if (!err)
> + err = put_user(len, optlen);
> + return err;
>
> case CAN_RAW_JOIN_FILTERS:
> if (len > sizeof(int))
> len = sizeof(int);
> val = &ro->join_filters;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] can: raw: fix getsockopt() for new CAN_RAW_XL_VCID_OPTS
2024-02-19 20:00 [PATCH] can: raw: fix getsockopt() for new CAN_RAW_XL_VCID_OPTS Oliver Hartkopp
2024-02-19 20:23 ` Oliver Hartkopp
@ 2024-02-20 7:26 ` Marc Kleine-Budde
1 sibling, 0 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2024-02-20 7:26 UTC (permalink / raw)
To: Oliver Hartkopp; +Cc: linux-can, netdev, Simon Horman
[-- Attachment #1: Type: text/plain, Size: 755 bytes --]
On 19.02.2024 21:00:21, Oliver Hartkopp wrote:
> The code for the CAN_RAW_XL_VCID_OPTS getsockopt() was incompletely adopted
> from the CAN_RAW_FILTER getsockopt().
>
> Add the missing put_user() and return statements.
>
> Flagged by Smatch.
> Fixes: c83c22ec1493 ("can: canxl: add virtual CAN network identifier support")
> Reported-by: Simon Horman <horms@kernel.org>
> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Applied to linux-can-next
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-20 7:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19 20:00 [PATCH] can: raw: fix getsockopt() for new CAN_RAW_XL_VCID_OPTS Oliver Hartkopp
2024-02-19 20:23 ` Oliver Hartkopp
2024-02-20 7:26 ` Marc Kleine-Budde
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).