linux-xiaomi-chiron/drivers/net/can/usb/etas_es58x
Vincent Mailhol 7a8cd7c0ee can: etas_es58x: es58x_fd_rx_event_msg(): initialize rx_event_msg before calling es58x_check_msg_len()
Function es58x_fd_rx_event() invokes the es58x_check_msg_len() macro:

| 	ret = es58x_check_msg_len(es58x_dev->dev, *rx_event_msg, msg_len);

While doing so, it dereferences an uninitialized
variable: *rx_event_msg.

This is actually harmless because es58x_check_msg_len() only uses
preprocessor macros (sizeof() and __stringify()) on
*rx_event_msg. c.f. [1].

Nonetheless, this pattern is confusing so the lines are reordered to
make sure that rx_event_msg is correctly initialized.

This patch also fixes a false positive warning reported by cppcheck:

| cppcheck possible warnings: (new ones prefixed by >>, may not be real problems)
|
|    In file included from drivers/net/can/usb/etas_es58x/es58x_fd.c:
| >> drivers/net/can/usb/etas_es58x/es58x_fd.c:174:8: warning: Uninitialized variable: rx_event_msg [uninitvar]
|     ret = es58x_check_msg_len(es58x_dev->dev, *rx_event_msg, msg_len);
|           ^

[1] https://elixir.bootlin.com/linux/v5.16/source/drivers/net/can/usb/etas_es58x/es58x_core.h#L467

Link: https://lore.kernel.org/all/20220306101302.708783-1-mailhol.vincent@wanadoo.fr
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-03-10 09:23:45 +01:00
..
es58x_core.c can: etas_es58x: change opened_channel_cnt's type from atomic_t to u8 2022-02-25 09:14:34 +01:00
es58x_core.h can: etas_es58x: change opened_channel_cnt's type from atomic_t to u8 2022-02-25 09:14:34 +01:00
es58x_fd.c can: etas_es58x: es58x_fd_rx_event_msg(): initialize rx_event_msg before calling es58x_check_msg_len() 2022-03-10 09:23:45 +01:00
es58x_fd.h treewide: Replace open-coded flex arrays in unions 2021-10-18 12:28:53 -07:00
es581_4.c can: bittiming: replace CAN units with the generic ones from linux/units.h 2021-12-08 10:12:58 +01:00
es581_4.h treewide: Replace open-coded flex arrays in unions 2021-10-18 12:28:53 -07:00
Makefile can: etas_es58x: add support for the ETAS ES58X_FD CAN USB interfaces 2021-04-13 10:15:43 +02:00