Skip to contentSkip to conversation

usbnet: pegasus: endian bug in write_mii_word()

PATCH In review Dan Carpenter 3 participants 3 messages May 3, 2013

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usbnet: pegasus: endian bug in write_mii_word()

We're only passing the two high bits of an integer. It works for little endian but not for big endian.

drivers/net/usb/pegasus.c +2 -1
index 0969905..03e8a15 100644
@@ -256,8 +256,9 @@ static int mdio_read(struct net_device *dev, int phy_id, int loc)
 static void mdio_write(struct net_device *dev, int phy_id, int loc, int val)
 {
 	pegasus_t *pegasus = netdev_priv(dev);
+	u16 data = val;
 
-	write_mii_word(pegasus, phy_id, loc, (__u16 *)&val);
+	write_mii_word(pegasus, phy_id, loc, &data);
 }
 
 static int read_eprom_word(pegasus_t *pegasus, __u8 index, __u16 *retdata)
#1 lore raw
Quoted 1 line

We're only passing the two high bits of an integer. It works for little

                                  ^^^^ bytes
Quoted 23 lines

endian but not for big endian.

drivers/net/usb/pegasus.c +2 -2
index 0969905..03e8a15 100644
@@ -256,8 +256,9 @@ static int mdio_read(struct net_device *dev, int phy_id, int loc)
 static void mdio_write(struct net_device *dev, int phy_id, int loc, int val)
 {
 	pegasus_t *pegasus = netdev_priv(dev);
+	u16 data = val;
 
-	write_mii_word(pegasus, phy_id, loc, (__u16 *)&val);
+	write_mii_word(pegasus, phy_id, loc, &data);
 }
 
 static int read_eprom_word(pegasus_t *pegasus, __u8 index, __u16 *retdata)
--

To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html