Commit acfa5110b83b171ec509eaf2d1a9e93a5f4709bd

Authored by Pekka Enberg
Committed by Greg Kroah-Hartman
1 parent 05e361cae5

Staging: w35und: fix usb_control_msg() error handling in wb35_probe()

If successful, the usb_control_msg() function returns the number of
bytes transferred. Fix up wb35_probe() to only bail out if the function returns
a negative number. Also, fix up ieee80211_alloc_hw() error code to ENOMEM;
otherwise GCC complains that err might be undefined (and is right about that).

Acked-by: Pavel Machek <pavel@suse.cz>
Reported-and-tested-by: Sandro Bonazzola <sandro.bonazzola@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 1 changed file with 10 additions and 6 deletions Side-by-side Diff

drivers/staging/winbond/wbusb.c
... ... @@ -319,16 +319,18 @@
319 319 struct usb_device *udev = interface_to_usbdev(intf);
320 320 struct wbsoft_priv *priv;
321 321 struct ieee80211_hw *dev;
322   - int err;
  322 + int nr, err;
323 323  
324 324 usb_get_dev(udev);
325 325  
326 326 // 20060630.2 Check the device if it already be opened
327   - err = usb_control_msg(udev, usb_rcvctrlpipe( udev, 0 ),
328   - 0x01, USB_TYPE_VENDOR|USB_RECIP_DEVICE|USB_DIR_IN,
329   - 0x0, 0x400, &ltmp, 4, HZ*100 );
330   - if (err)
  327 + nr = usb_control_msg(udev, usb_rcvctrlpipe( udev, 0 ),
  328 + 0x01, USB_TYPE_VENDOR|USB_RECIP_DEVICE|USB_DIR_IN,
  329 + 0x0, 0x400, &ltmp, 4, HZ*100 );
  330 + if (nr < 0) {
  331 + err = nr;
331 332 goto error;
  333 + }
332 334  
333 335 ltmp = cpu_to_le32(ltmp);
334 336 if (ltmp) { // Is already initialized?
335 337  
... ... @@ -337,8 +339,10 @@
337 339 }
338 340  
339 341 dev = ieee80211_alloc_hw(sizeof(*priv), &wbsoft_ops);
340   - if (!dev)
  342 + if (!dev) {
  343 + err = -ENOMEM;
341 344 goto error;
  345 + }
342 346  
343 347 priv = dev->priv;
344 348