From fb3e5ec1f032f0f0ed946ad796ecb81e7550650a Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sun, 26 May 2024 19:23:40 +0000 Subject: [PATCH 1/2] drivers: can: shell: fully initialize frame before sending Zerorise the CAN frame before filling in data to ensure all data bytes are initialized. Fixes: #73309 Signed-off-by: Henrik Brix Andersen (cherry picked from commit fb4f67b77503ad143d98cc1b2c73ca448850900e) --- drivers/can/can_shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/can/can_shell.c b/drivers/can/can_shell.c index e07de338952fac..c53968d3a69f01 100644 --- a/drivers/can/can_shell.c +++ b/drivers/can/can_shell.c @@ -560,7 +560,7 @@ static int cmd_can_send(const struct shell *sh, size_t argc, char **argv) const struct device *dev = device_get_binding(argv[1]); static unsigned int frame_counter; unsigned int frame_no; - struct can_frame frame; + struct can_frame frame = { 0 }; uint32_t max_id; int argidx = 2; uint32_t val; From 71af368efb89f89e9af17036287319067685c0ed Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sun, 26 May 2024 19:34:26 +0000 Subject: [PATCH 2/2] drivers: can: shell: print raw DLC when sending frame, not bytes Print the raw DLC when enqueuing a CAN frame for sending, not the corresponding number of bytes. Fixes: #73309 Signed-off-by: Henrik Brix Andersen (cherry picked from commit 6a070ee165fe39b2fcbfd365102165ab362dce2f) --- drivers/can/can_shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/can/can_shell.c b/drivers/can/can_shell.c index c53968d3a69f01..a1828be26c60f1 100644 --- a/drivers/can/can_shell.c +++ b/drivers/can/can_shell.c @@ -665,7 +665,7 @@ static int cmd_can_send(const struct shell *sh, size_t argc, char **argv) (frame.flags & CAN_FRAME_RTR) != 0 ? 1 : 0, (frame.flags & CAN_FRAME_FDF) != 0 ? 1 : 0, (frame.flags & CAN_FRAME_BRS) != 0 ? 1 : 0, - can_dlc_to_bytes(frame.dlc)); + frame.dlc); err = can_send(dev, &frame, K_NO_WAIT, can_shell_tx_callback, UINT_TO_POINTER(frame_no)); if (err != 0) {