Skip to content

Commit

Permalink
Staging: w35und: fix usb_control_msg() error handling in wb35_probe()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Pekka Enberg authored and Greg Kroah-Hartman committed Feb 27, 2009
1 parent 05e361c commit acfa511
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions drivers/staging/winbond/wbusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,18 @@ static int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id
struct usb_device *udev = interface_to_usbdev(intf);
struct wbsoft_priv *priv;
struct ieee80211_hw *dev;
int err;
int nr, err;

usb_get_dev(udev);

// 20060630.2 Check the device if it already be opened
err = usb_control_msg(udev, usb_rcvctrlpipe( udev, 0 ),
0x01, USB_TYPE_VENDOR|USB_RECIP_DEVICE|USB_DIR_IN,
0x0, 0x400, &ltmp, 4, HZ*100 );
if (err)
nr = usb_control_msg(udev, usb_rcvctrlpipe( udev, 0 ),
0x01, USB_TYPE_VENDOR|USB_RECIP_DEVICE|USB_DIR_IN,
0x0, 0x400, &ltmp, 4, HZ*100 );
if (nr < 0) {
err = nr;
goto error;
}

ltmp = cpu_to_le32(ltmp);
if (ltmp) { // Is already initialized?
Expand All @@ -337,8 +339,10 @@ static int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id
}

dev = ieee80211_alloc_hw(sizeof(*priv), &wbsoft_ops);
if (!dev)
if (!dev) {
err = -ENOMEM;
goto error;
}

priv = dev->priv;

Expand Down

0 comments on commit acfa511

Please sign in to comment.