diff mbox

[U-Boot] smsc95xx: fix operation on 64-bit systems

Message ID 1458707296-16271-1-git-send-email-swarren@wwwdotorg.org
State Accepted
Commit e320f0bc9b81076e4c59d281dff1428df5324809
Delegated to: Tom Rini
Headers show

Commit Message

Stephen Warren March 23, 2016, 4:28 a.m. UTC
smsc95xx_read_reg() should calculate sizeof(*data) not sizeof(data) since
data is a pointer, and the value pointed at is being transferred over USB,
not the value of the pointer. This fixes operation of the driver in 64-bit
builds, such as the Raspberry Pi 3.

Reported-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
---
 drivers/usb/eth/smsc95xx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Marek Vasut March 23, 2016, 5:03 a.m. UTC | #1
On 03/23/2016 05:28 AM, Stephen Warren wrote:
> smsc95xx_read_reg() should calculate sizeof(*data) not sizeof(data) since
> data is a pointer, and the value pointed at is being transferred over USB,
> not the value of the pointer. This fixes operation of the driver in 64-bit
> builds, such as the Raspberry Pi 3.

Thanks!

Acked-by: Marek Vasut <marex@denx.de>

> Reported-by: Eric Anholt <eric@anholt.net>
> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
> ---
>  drivers/usb/eth/smsc95xx.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/eth/smsc95xx.c b/drivers/usb/eth/smsc95xx.c
> index 3099bf4fd4e5..08eaed5c2e03 100644
> --- a/drivers/usb/eth/smsc95xx.c
> +++ b/drivers/usb/eth/smsc95xx.c
> @@ -188,10 +188,10 @@ static int smsc95xx_read_reg(struct usb_device *udev, u32 index, u32 *data)
>  	len = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
>  			      USB_VENDOR_REQUEST_READ_REGISTER,
>  			      USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> -			      0, index, tmpbuf, sizeof(data),
> +			      0, index, tmpbuf, sizeof(*data),
>  			      USB_CTRL_GET_TIMEOUT);
>  	*data = tmpbuf[0];
> -	if (len != sizeof(data)) {
> +	if (len != sizeof(*data)) {
>  		debug("smsc95xx_read_reg failed: index=%d, len=%d",
>  		      index, len);
>  		return -EIO;
>
Joe Hershberger March 23, 2016, 4:15 p.m. UTC | #2
On Tue, Mar 22, 2016 at 11:28 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> smsc95xx_read_reg() should calculate sizeof(*data) not sizeof(data) since
> data is a pointer, and the value pointed at is being transferred over USB,
> not the value of the pointer. This fixes operation of the driver in 64-bit
> builds, such as the Raspberry Pi 3.
>
> Reported-by: Eric Anholt <eric@anholt.net>
> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Tom Rini April 2, 2016, 1:55 a.m. UTC | #3
On Tue, Mar 22, 2016 at 10:28:16PM -0600, Stephen Warren wrote:

> smsc95xx_read_reg() should calculate sizeof(*data) not sizeof(data) since
> data is a pointer, and the value pointed at is being transferred over USB,
> not the value of the pointer. This fixes operation of the driver in 64-bit
> builds, such as the Raspberry Pi 3.
> 
> Reported-by: Eric Anholt <eric@anholt.net>
> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
> Acked-by: Marek Vasut <marex@denx.de>
> Acked-by: Joe Hershberger <joe.hershberger@ni.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/drivers/usb/eth/smsc95xx.c b/drivers/usb/eth/smsc95xx.c
index 3099bf4fd4e5..08eaed5c2e03 100644
--- a/drivers/usb/eth/smsc95xx.c
+++ b/drivers/usb/eth/smsc95xx.c
@@ -188,10 +188,10 @@  static int smsc95xx_read_reg(struct usb_device *udev, u32 index, u32 *data)
 	len = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
 			      USB_VENDOR_REQUEST_READ_REGISTER,
 			      USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-			      0, index, tmpbuf, sizeof(data),
+			      0, index, tmpbuf, sizeof(*data),
 			      USB_CTRL_GET_TIMEOUT);
 	*data = tmpbuf[0];
-	if (len != sizeof(data)) {
+	if (len != sizeof(*data)) {
 		debug("smsc95xx_read_reg failed: index=%d, len=%d",
 		      index, len);
 		return -EIO;