From: Stéphane Grosjean <s.gr…@peak-system.fr> peak_usb_restart() allocates the buffer of the asynchronous restart command with kmalloc(), and lets the dev_restart_async() callback of the adapter build the command in it. None of these callbacks fills the whole part of the buffer that it sends to the device: - pcan_usb_restart_async() sets 3 of the PCAN_USB_CMD_LEN (16) bytes that it sends; - pcan_usb_pro_restart_async() builds an 8-byte message, but sends the whole PCAN_USB_MAX_CMD_LEN (32) bytes buffer; - pcan_usb_fd_build_restart_cmd() leaves the unused field of struct pucan_wr_err_cnt and the args of the final struct pucan_command unset. Uninitialized heap bytes are thus sent to the device each time a channel is restarted after bus off. Allocate the buffer with kzalloc(), so that the unset bytes are zero, as for the other command buffers of the driver. Found while checking the other adapters for the uninitialized command bytes reported by Sashiko AI review. Fixes: bb4785551f64 ("can: usb: PEAK-System Technik USB adapters driver core") Cc: stab…@vger.kernel.org Signed-off-by: Stéphane Grosjean <s.gr…@peak-system.fr> Link: https://patch.msgid.link/2026…@peak-system.fr Signed-off-by: Marc Kleine-Budde <m…@pengutronix.de> --- drivers/net/can/usb/peak_usb/pcan_usb_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c index 1d306160fa35..95c1454b4116 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c @@ -702,7 +702,7 @@ static int peak_usb_restart(struct peak_usb_device *dev) return -ENOMEM; /* also allocate enough space for the commands to send */ - buf = kmalloc(PCAN_USB_MAX_CMD_LEN, GFP_ATOMIC); + buf = kzalloc(PCAN_USB_MAX_CMD_LEN, GFP_ATOMIC); if (!buf) { usb_free_urb(urb); return -ENOMEM;
-- 2.53.0