diff mbox

fix sierra_net endianess bug

Message ID 4F60A695.4040601@mt.lv
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Maris Paupe March 14, 2012, 2:09 p.m. UTC
Hello,
I have found that sierra_net does not work properly on big-endian
systems, it works if bytes are flipped in this particular location.

Signed-off-by: Maris Paupe <marisp@mt.lv>
---
---
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Andreas Schwab March 14, 2012, 3:26 p.m. UTC | #1
Maris Paupe <marisp@mt.lv> writes:

> I have found that sierra_net does not work properly on big-endian
> systems, it works if bytes are flipped in this particular location.

That should probably be fixed in sierra_net_get_fw_attr (and the author
of sierra_net_get_fw_attr should be hit with a cluestick to not use
kmalloc for allocating a single u16).

Andreas.
Ben Hutchings March 14, 2012, 7:24 p.m. UTC | #2
On Wed, 2012-03-14 at 16:26 +0100, Andreas Schwab wrote:
> Maris Paupe <marisp@mt.lv> writes:
> 
> > I have found that sierra_net does not work properly on big-endian
> > systems, it works if bytes are flipped in this particular location.
> 
> That should probably be fixed in sierra_net_get_fw_attr (and the author
> of sierra_net_get_fw_attr should be hit with a cluestick to not use
> kmalloc for allocating a single u16).

You cannot use stack buffers for DMA, which includes all USB I/O.

Ben.
Andreas Schwab March 14, 2012, 9:10 p.m. UTC | #3
Ben Hutchings <bhutchings@solarflare.com> writes:

> On Wed, 2012-03-14 at 16:26 +0100, Andreas Schwab wrote:
>> Maris Paupe <marisp@mt.lv> writes:
>> 
>> > I have found that sierra_net does not work properly on big-endian
>> > systems, it works if bytes are flipped in this particular location.
>> 
>> That should probably be fixed in sierra_net_get_fw_attr (and the author
>> of sierra_net_get_fw_attr should be hit with a cluestick to not use
>> kmalloc for allocating a single u16).
>
> You cannot use stack buffers for DMA, which includes all USB I/O.

Ok, sorry, I didn't know that.

Andreas.
diff mbox

Patch

diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
index b59cf20..cf11924 100644
--- a/drivers/net/usb/sierra_net.c
+++ b/drivers/net/usb/sierra_net.c
@@ -779,7 +779,7 @@  static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
  	dev_dbg(&dev->udev->dev, "Fw attr: %x\n", fwattr);
  
  	/* test whether firmware supports DHCP */
-	if (!(status == sizeof(fwattr) && (fwattr & SWI_GET_FW_ATTR_MASK))) {
+	if (!(status == sizeof(fwattr) && (le16_to_cpu(fwattr) & SWI_GET_FW_ATTR_MASK))) {
  		/* found incompatible firmware version */
  		dev_err(&dev->udev->dev, "Incompatible driver and firmware"
  			" versions\n");