linux-stable/drivers/net/can/usb
Marc Kleine-Budde f006229135 can: kvaser_usb: hydra: help gcc-13 to figure out cmd_len
Debian's gcc-13 [1] throws the following error in
kvaser_usb_hydra_cmd_size():

[1] gcc version 13.0.0 20221214 (experimental) [master r13-4693-g512098a3316] (Debian 13-20221214-1)

| drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:502:65: error:
| array subscript ‘struct kvaser_cmd_ext[0]’ is partly outside array
| bounds of ‘unsigned char[32]’ [-Werror=array-bounds=]
|   502 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);

kvaser_usb_hydra_cmd_size() returns the size of given command. It
depends on the command number (cmd->header.cmd_no). For extended
commands (cmd->header.cmd_no == CMD_EXTENDED) the above shown code is
executed.

Help gcc to recognize that this code path is not taken in all cases,
by calling kvaser_usb_hydra_cmd_size() directly after assigning the
command number.

Fixes: aec5fb2268 ("can: kvaser_usb: Add support for Kvaser USB hydra family")
Cc: Jimmy Assarsson <extja@kvaser.com>
Cc: Anssi Hannula <anssi.hannula@bitwise.fi>
Link: https://lore.kernel.org/all/20221219110104.1073881-1-mkl@pengutronix.de
Tested-by: Jimmy Assarsson <extja@kvaser.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-12-19 16:08:27 +01:00
..
etas_es58x can: etas_es58x: remove es58x_get_product_info() 2022-12-12 11:39:13 +01:00
kvaser_usb can: kvaser_usb: hydra: help gcc-13 to figure out cmd_len 2022-12-19 16:08:27 +01:00
peak_usb can: dev: fix skb drop check 2022-11-07 14:00:27 +01:00
ems_usb.c can: dev: fix skb drop check 2022-11-07 14:00:27 +01:00
esd_usb.c can: esd_usb: Allow REC and TEC to return to zero 2022-12-07 10:32:48 +01:00
gs_usb.c can: gs_usb: remove gs_can::iface 2022-12-12 11:41:25 +01:00
Kconfig can: etas_es58x: add devlink support 2022-12-12 11:39:12 +01:00
Makefile can/esd_usb2: Rename esd_usb2.c to esd_usb.c 2022-06-25 13:05:26 +02:00
mcba_usb.c can: mcba_usb: Fix termination command argument 2022-11-24 16:26:48 +01:00
ucan.c can: ucan: remove unused ucan_priv::intf 2022-12-12 11:41:25 +01:00
usb_8dev.c can: dev: fix skb drop check 2022-11-07 14:00:27 +01:00