History

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.

Marc Kleine-Budde committed 4 years ago

Commit 0ff32bf1 parent d5a972f1 file · +1 −1Browse files

Unified · Split

drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c+1−1
@@ -1778,7 +1778,7 @@ mcp251xfd_register_get_dev_id(const struct mcp251xfd_priv *priv, u32 *dev_id, · 1777 unmodified lines
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);