]> git.baikalelectronics.ru Git - kernel.git/commit
can: mcp251xfd: mcp251xfd_register_get_dev_id(): use correct length to read dev_id
authorMarc Kleine-Budde <mkl@pengutronix.de>
Thu, 16 Jun 2022 09:38:00 +0000 (11:38 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 4 Jul 2022 10:46:46 +0000 (12:46 +0200)
commit4f4b39b3444a4350c6339ed483b2668541e8d8b2
tree57c3783682be67f2773ac90b764f0142c3d6a0e9
parent6bc93919829d548df41d1c9408f3b2cf3038dab4
can: mcp251xfd: mcp251xfd_register_get_dev_id(): use correct length to read dev_id

The device ID register is 32 bits wide. The driver uses incorrectly
the size of a pointer to a u32 to calculate the length of the SPI
transfer. This results in a read of 2 registers on 64 bit platforms.
This is no problem on the Linux side, as the RX buffer of the SPI
transfer is large enough. In the mpc251xfd chip this results in the
read of an undocumented register. So far no problems were observed.

Fix the length of the SPI transfer to read the device ID register
only.

Link: https://lore.kernel.org/all/20220616094914.244440-1-mkl@pengutronix.de
Fixes: 74ed7c9bd838 ("can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN")
Reported-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c