All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org, kernel@pengutronix.de,
	Thomas Kopp <thomas.kopp@microchip.com>
Subject: Re: [PATCH] can: mcp251xfd: mcp251xfd_register_get_dev_id(): use correct length to read dev_id
Date: Fri, 24 Jun 2022 12:41:30 +0530	[thread overview]
Message-ID: <20220624071130.GA11407@thinkpad> (raw)
In-Reply-To: <20220616094914.244440-1-mkl@pengutronix.de>

On Thu, Jun 16, 2022 at 11:49:14AM +0200, Marc Kleine-Budde wrote:
> 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.
> 
> This patch fixes the length of the SPI transfer to read the device ID
> register only.
> 
> Fixes: 55e5b97f003e ("can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN")
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Thanks,
Mani

> ---
>  drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
> index 34b160024ce3..3160881e89d9 100644
> --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
> +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
> @@ -1778,7 +1778,7 @@ mcp251xfd_register_get_dev_id(const struct mcp251xfd_priv *priv, u32 *dev_id,
>  	xfer[0].len = sizeof(buf_tx->cmd);
>  	xfer[0].speed_hz = priv->spi_max_speed_hz_slow;
>  	xfer[1].rx_buf = buf_rx->data;
> -	xfer[1].len = sizeof(dev_id);
> +	xfer[1].len = sizeof(*dev_id);
>  	xfer[1].speed_hz = priv->spi_max_speed_hz_fast;
>  
>  	mcp251xfd_spi_cmd_read_nocrc(&buf_tx->cmd, MCP251XFD_REG_DEVID);
> -- 
> 2.35.1
> 
> 

-- 
மணிவண்ணன் சதாசிவம்

      reply	other threads:[~2022-06-24  7:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-16  9:49 [PATCH] can: mcp251xfd: mcp251xfd_register_get_dev_id(): use correct length to read dev_id Marc Kleine-Budde
2022-06-24  7:11 ` Manivannan Sadhasivam [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220624071130.GA11407@thinkpad \
    --to=manivannan.sadhasivam@linaro.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=thomas.kopp@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.