All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org,
	kernel@pengutronix.de, Oliver Hartkopp <socketcan@hartkopp.net>,
	Simon Horman <horms@kernel.org>,
	Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH net-next 8/9] can: raw: fix getsockopt() for new CAN_RAW_XL_VCID_OPTS
Date: Tue, 20 Feb 2024 09:46:10 +0100	[thread overview]
Message-ID: <20240220085130.2936533-9-mkl@pengutronix.de> (raw)
In-Reply-To: <20240220085130.2936533-1-mkl@pengutronix.de>

From: Oliver Hartkopp <socketcan@hartkopp.net>

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>
Link: https://lore.kernel.org/all/20240219200021.12113-1-socketcan@hartkopp.net
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 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
@@ -835,7 +835,9 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,
 			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))
-- 
2.43.0



  parent reply	other threads:[~2024-02-20  8:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-20  8:46 [PATCH net-next 0/9] pull-request: can-next 2024-02-20 Marc Kleine-Budde
2024-02-20  8:46 ` [PATCH net-next 1/9] can: m_can: remove redundant check for pm_clock_support Marc Kleine-Budde
2024-02-20 14:40   ` patchwork-bot+netdevbpf
2024-02-20  8:46 ` [PATCH net-next 2/9] dt-bindings: can: tcan4x5x: Document the wakeup-source flag Marc Kleine-Budde
2024-02-20  8:46 ` [PATCH net-next 3/9] can: m_can: allow keeping the transceiver running in suspend Marc Kleine-Budde
2024-02-20  8:46 ` [PATCH net-next 4/9] can: tcan4x5x: support resuming from rx interrupt signal Marc Kleine-Budde
2024-02-20  8:46 ` [PATCH net-next 5/9] dt-bindings: can: xilinx_can: Add 'xlnx,has-ecc' optional property Marc Kleine-Budde
2024-02-20  8:46 ` [PATCH net-next 6/9] can: xilinx_can: Add ECC support Marc Kleine-Budde
2024-02-20  8:46 ` [PATCH net-next 7/9] can: xilinx_can: Add ethtool stats interface for ECC errors Marc Kleine-Budde
2024-02-20  8:46 ` Marc Kleine-Budde [this message]
2024-02-20  8:46 ` [PATCH net-next 9/9] can: raw: raw_getsockopt(): reduce scope of err Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240220085130.2936533-9-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=davem@davemloft.net \
    --cc=horms@kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=socketcan@hartkopp.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.