Skip to content

Commit 0ff32bf

Browse files
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/[email protected] Fixes: 55e5b97 ("can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN") Reported-by: Rasmus Villemoes <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent d5a972f commit 0ff32bf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ mcp251xfd_register_get_dev_id(const struct mcp251xfd_priv *priv, u32 *dev_id,
17781778
xfer[0].len = sizeof(buf_tx->cmd);
17791779
xfer[0].speed_hz = priv->spi_max_speed_hz_slow;
17801780
xfer[1].rx_buf = buf_rx->data;
1781-
xfer[1].len = sizeof(dev_id);
1781+
xfer[1].len = sizeof(*dev_id);
17821782
xfer[1].speed_hz = priv->spi_max_speed_hz_fast;
17831783

17841784
mcp251xfd_spi_cmd_read_nocrc(&buf_tx->cmd, MCP251XFD_REG_DEVID);

0 commit comments

Comments
 (0)