can: raw: fix getsockopt() for new CAN_RAW_XL_VCID_OPTS
Subsystems (4)
Oliver Hartkopp
maintainerPATCH 1/1 can: raw: fix getsockopt() for new CAN_RAW_XL_VCID_OPTS
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 <[email protected]>
Signed-off-by Oliver Hartkopp <[email protected]>
--- net/can/raw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/can/raw.c +3 -1
@@ -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;
Signature · 1 line
2.43.0
Oliver Hartkopp
maintainerSorry. Of course it is a [PATCH net-next] where the referenced commit has been applied.
Best regards,
Oliver
Quoted 32 lines · Oliver Hartkopp
The code for the
CAN_RAW_XL_VCID_OPTSgetsockopt()was incompletely adopted from theCAN_RAW_FILTERgetsockopt().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 <[email protected]>Signed-off-by Oliver Hartkopp <[email protected]>--- net/can/raw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)net/can/raw.c +3
-1@@ -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;
Quoted 9 lines · Oliver Hartkopp
The code for the
CAN_RAW_XL_VCID_OPTSgetsockopt()was incompletely adopted from theCAN_RAW_FILTERgetsockopt().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 <[email protected]>Signed-off-by Oliver Hartkopp <[email protected]>
Applied to linux-can-next
regards,
Marc
Signature · 4 lines
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 |