public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Michael Buesch <mb@bu3sch.de>,
	"David S. Miller" <davem@davemloft.net>
Subject: [patch 31/37] pegasus usb-net: Fix endianness bugs
Date: Tue, 28 Jul 2009 15:58:59 -0700	[thread overview]
Message-ID: <20090728225945.550576241@mini.kroah.org> (raw)
In-Reply-To: <20090728230145.GA10486@kroah.com>

[-- Attachment #1: pegasus-usb-net-fix-endianness-bugs.patch --]
[-- Type: text/plain, Size: 3081 bytes --]


2.6.27-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Michael Buesch <mb@bu3sch.de>

[ Upstream commit e3453f6342110d60edb37be92c4a4f668ca8b0c4 ]

This fixes various endianness bugs. Some harmless and some real ones.
This is tested on a PowerPC-64 machine.

Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/net/usb/pegasus.c |   29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

--- a/drivers/net/usb/pegasus.c
+++ b/drivers/net/usb/pegasus.c
@@ -295,7 +295,7 @@ static int update_eth_regs_async(pegasus
 
 	pegasus->dr.bRequestType = PEGASUS_REQT_WRITE;
 	pegasus->dr.bRequest = PEGASUS_REQ_SET_REGS;
-	pegasus->dr.wValue = 0;
+	pegasus->dr.wValue = cpu_to_le16(0);
 	pegasus->dr.wIndex = cpu_to_le16(EthCtrl0);
 	pegasus->dr.wLength = cpu_to_le16(3);
 	pegasus->ctrl_urb->transfer_buffer_length = 3;
@@ -444,11 +444,12 @@ static int write_eprom_word(pegasus_t * 
 	int i;
 	__u8 tmp, d[4] = { 0x3f, 0, 0, EPROM_WRITE };
 	int ret;
+	__le16 le_data = cpu_to_le16(data);
 
 	set_registers(pegasus, EpromOffset, 4, d);
 	enable_eprom_write(pegasus);
 	set_register(pegasus, EpromOffset, index);
-	set_registers(pegasus, EpromData, 2, &data);
+	set_registers(pegasus, EpromData, 2, &le_data);
 	set_register(pegasus, EpromCtrl, EPROM_WRITE);
 
 	for (i = 0; i < REG_TIMEOUT; i++) {
@@ -918,29 +919,32 @@ static struct net_device_stats *pegasus_
 
 static inline void disable_net_traffic(pegasus_t * pegasus)
 {
-	int tmp = 0;
+	__le16 tmp = cpu_to_le16(0);
 
-	set_registers(pegasus, EthCtrl0, 2, &tmp);
+	set_registers(pegasus, EthCtrl0, sizeof(tmp), &tmp);
 }
 
 static inline void get_interrupt_interval(pegasus_t * pegasus)
 {
-	__u8 data[2];
+	u16 data;
+	u8 interval;
 
-	read_eprom_word(pegasus, 4, (__u16 *) data);
+	read_eprom_word(pegasus, 4, &data);
+	interval = data >> 8;
 	if (pegasus->usb->speed != USB_SPEED_HIGH) {
-		if (data[1] < 0x80) {
+		if (interval < 0x80) {
 			if (netif_msg_timer(pegasus))
 				dev_info(&pegasus->intf->dev, "intr interval "
 					"changed from %ums to %ums\n",
-					data[1], 0x80);
-			data[1] = 0x80;
+					interval, 0x80);
+			interval = 0x80;
+			data = (data & 0x00FF) | ((u16)interval << 8);
 #ifdef PEGASUS_WRITE_EEPROM
-			write_eprom_word(pegasus, 4, *(__u16 *) data);
+			write_eprom_word(pegasus, 4, data);
 #endif
 		}
 	}
-	pegasus->intr_interval = data[1];
+	pegasus->intr_interval = interval;
 }
 
 static void set_carrier(struct net_device *net)
@@ -1293,7 +1297,8 @@ static int pegasus_blacklisted(struct us
 	/* Special quirk to keep the driver from handling the Belkin Bluetooth
 	 * dongle which happens to have the same ID.
 	 */
-	if ((udd->idVendor == VENDOR_BELKIN && udd->idProduct == 0x0121) &&
+	if ((udd->idVendor == cpu_to_le16(VENDOR_BELKIN)) &&
+	    (udd->idProduct == cpu_to_le16(0x0121)) &&
 	    (udd->bDeviceClass == USB_CLASS_WIRELESS_CONTROLLER) &&
 	    (udd->bDeviceProtocol == 1))
 		return 1;



  parent reply	other threads:[~2009-07-28 23:04 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090728225828.431071451@mini.kroah.org>
2009-07-28 23:01 ` [patch 00/37] 2.6.27.29-stable review Greg KH
2009-07-28 22:58   ` [patch 01/37] fix RCU-callback-after-kmem_cache_destroy problem in sl[aou]b Greg KH
2009-07-28 22:58   ` [patch 02/37] gigaset: accept connection establishment messages in any order Greg KH
2009-07-28 22:58   ` [patch 03/37] SCSI: zalon: fix oops on attach failure Greg KH
2009-07-28 22:58   ` [patch 04/37] sound: usb-audio: add workaround for Blue Microphones devices Greg KH
2009-07-28 22:58   ` [patch 05/37] sound: virtuoso: fix Xonar D1/DX silence after resume Greg KH
2009-07-28 22:58   ` [patch 06/37] USB: EHCI: report actual_length for iso transfers Greg KH
2009-07-28 22:58   ` [patch 07/37] USB: fix memleak in usbfs Greg KH
2009-07-28 22:58   ` [patch 08/37] USB: fix uninitialised variable in ti_do_download Greg KH
2009-07-28 22:58   ` [patch 09/37] USB: handle zero-length usbfs submissions correctly Greg KH
2009-07-28 22:58   ` [patch 10/37] USB: RNDIS gadget, fix issues talking from PXA Greg KH
2009-07-28 22:58   ` [patch 11/37] USB: ti_usb_3410_5052: fix duplicate device ids Greg KH
2009-07-28 22:58   ` [patch 12/37] ALSA: ca0106 - Fix the max capture buffer size Greg KH
2009-07-28 22:58   ` [patch 13/37] ALSA: hda - Fix mute control with some ALC262 models Greg KH
2009-07-28 22:58   ` [patch 14/37] HID: hiddev, fix lock imbalance Greg KH
2009-07-28 22:58   ` [patch 15/37] elf: fix one check-after-use Greg KH
2009-07-28 22:58   ` [patch 16/37] hwmon: (max6650) Fix lock imbalance Greg KH
2009-07-28 22:58   ` [patch 17/37] md: avoid dereferencing NULL pointer when accessing suspend_* sysfs attributes Greg KH
2009-07-28 22:58   ` [patch 18/37] mm: mark page accessed before we write_end() Greg KH
2009-07-28 22:58   ` [patch 19/37] x86-64: Fix bad_srat() to clear all state Greg KH
2009-07-28 22:58   ` [patch 20/37] x86: dont use access_ok() as a range check in get_user_pages_fast() Greg KH
2009-07-28 22:58   ` [patch 21/37] SUNRPC: Avoid an unnecessary task reschedule on ENOTCONN Greg KH
2009-07-28 22:58   ` [patch 22/37] SUNRPC: Ensure we set XPRT_CLOSING only after weve sent a tcp FIN Greg KH
2009-07-28 22:58   ` [patch 23/37] SUNRPC: Dont disconnect if a connection is still in progress Greg KH
2009-07-28 22:58   ` [patch 24/37] ACPI: EC: Limit workaround for ASUS notebooks even more Greg KH
2009-07-28 22:58   ` [patch 25/37] Enable PNPACPI _PSx Support, v3 Greg KH
2009-07-28 22:58   ` [patch 26/37] ACPI: suspend: dont let device _PS3 failure prevent suspend Greg KH
2009-07-28 22:58   ` [patch 27/37] Input: wistron_btns - recognize Maxdata Pro 7000 notebooks Greg KH
2009-07-28 22:58   ` [patch 28/37] eCryptfs: Check Tag 11 literal data buffer size (CVE-2009-2406) Greg KH
2009-07-28 22:58   ` [patch 29/37] eCryptfs: parse_tag_3_packet check tag 3 packet encrypted key size (CVE-2009-2407) Greg KH
2009-07-28 22:58   ` [patch 30/37] ipsec: Fix name of CAST algorithm Greg KH
2009-07-28 22:58   ` Greg KH [this message]
2009-07-28 22:59   ` [patch 32/37] sky2: Fix checksum endianness Greg KH
2009-07-28 22:59   ` [patch 33/37] x25: Fix sleep from timer on socket destroy Greg KH
2009-07-28 22:59   ` [patch 34/37] usbnet cdc_subset: fix issues talking to PXA gadgets Greg KH
2009-07-28 22:59   ` [patch 35/37] r8169: avoid losing MSI interrupts Greg KH
2009-07-28 22:59   ` [patch 36/37] E100: work around the driver using streaming DMA mapping for RX descriptors Greg KH
2009-07-28 22:59   ` [patch 37/37] NET: Fix locking issues in PPP, 6pack, mkiss and strip line disciplines Greg KH
2009-07-28 23:39   ` [patch 00/37] 2.6.27.29-stable review Greg KH

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=20090728225945.550576241@mini.kroah.org \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mb@bu3sch.de \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox