Commit cb1cebbe authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

usbnet: init fault (oops) cleanup, whitespace fixes

This cleans up some error handling paths in usbnet device probing;
one of them could cause oopsing, e.g. with some RNDIS devices.

It also removes some extraneous whitespace.
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 6e91f527
...@@ -147,7 +147,7 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf) ...@@ -147,7 +147,7 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
if (tmp < 0) if (tmp < 0)
return tmp; return tmp;
} }
dev->in = usb_rcvbulkpipe (dev->udev, dev->in = usb_rcvbulkpipe (dev->udev,
in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
dev->out = usb_sndbulkpipe (dev->udev, dev->out = usb_sndbulkpipe (dev->udev,
...@@ -327,7 +327,7 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags) ...@@ -327,7 +327,7 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
if (netif_running (dev->net) if (netif_running (dev->net)
&& netif_device_present (dev->net) && netif_device_present (dev->net)
&& !test_bit (EVENT_RX_HALT, &dev->flags)) { && !test_bit (EVENT_RX_HALT, &dev->flags)) {
switch (retval = usb_submit_urb (urb, GFP_ATOMIC)){ switch (retval = usb_submit_urb (urb, GFP_ATOMIC)){
case -EPIPE: case -EPIPE:
usbnet_defer_kevent (dev, EVENT_RX_HALT); usbnet_defer_kevent (dev, EVENT_RX_HALT);
break; break;
...@@ -443,7 +443,7 @@ static void rx_complete (struct urb *urb) ...@@ -443,7 +443,7 @@ static void rx_complete (struct urb *urb)
case -EOVERFLOW: case -EOVERFLOW:
dev->stats.rx_over_errors++; dev->stats.rx_over_errors++;
// FALLTHROUGH // FALLTHROUGH
default: default:
entry->state = rx_cleanup; entry->state = rx_cleanup;
dev->stats.rx_errors++; dev->stats.rx_errors++;
...@@ -560,7 +560,7 @@ static int usbnet_stop (struct net_device *net) ...@@ -560,7 +560,7 @@ static int usbnet_stop (struct net_device *net)
if (netif_msg_ifdown (dev)) if (netif_msg_ifdown (dev))
devinfo (dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld", devinfo (dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld",
dev->stats.rx_packets, dev->stats.tx_packets, dev->stats.rx_packets, dev->stats.tx_packets,
dev->stats.rx_errors, dev->stats.tx_errors dev->stats.rx_errors, dev->stats.tx_errors
); );
...@@ -578,7 +578,7 @@ static int usbnet_stop (struct net_device *net) ...@@ -578,7 +578,7 @@ static int usbnet_stop (struct net_device *net)
devdbg (dev, "waited for %d urb completions", temp); devdbg (dev, "waited for %d urb completions", temp);
} }
dev->wait = NULL; dev->wait = NULL;
remove_wait_queue (&unlink_wakeup, &wait); remove_wait_queue (&unlink_wakeup, &wait);
usb_kill_urb(dev->interrupt); usb_kill_urb(dev->interrupt);
...@@ -834,7 +834,7 @@ kevent (struct work_struct *work) ...@@ -834,7 +834,7 @@ kevent (struct work_struct *work)
} }
if (test_bit (EVENT_LINK_RESET, &dev->flags)) { if (test_bit (EVENT_LINK_RESET, &dev->flags)) {
struct driver_info *info = dev->driver_info; struct driver_info *info = dev->driver_info;
int retval = 0; int retval = 0;
clear_bit (EVENT_LINK_RESET, &dev->flags); clear_bit (EVENT_LINK_RESET, &dev->flags);
...@@ -1066,7 +1066,7 @@ static void usbnet_bh (unsigned long param) ...@@ -1066,7 +1066,7 @@ static void usbnet_bh (unsigned long param)
* USB Device Driver support * USB Device Driver support
* *
*-------------------------------------------------------------------------*/ *-------------------------------------------------------------------------*/
// precondition: never called in_interrupt // precondition: never called in_interrupt
void usbnet_disconnect (struct usb_interface *intf) void usbnet_disconnect (struct usb_interface *intf)
...@@ -1087,7 +1087,7 @@ void usbnet_disconnect (struct usb_interface *intf) ...@@ -1087,7 +1087,7 @@ void usbnet_disconnect (struct usb_interface *intf)
intf->dev.driver->name, intf->dev.driver->name,
xdev->bus->bus_name, xdev->devpath, xdev->bus->bus_name, xdev->devpath,
dev->driver_info->description); dev->driver_info->description);
net = dev->net; net = dev->net;
unregister_netdev (net); unregister_netdev (net);
...@@ -1111,7 +1111,7 @@ int ...@@ -1111,7 +1111,7 @@ int
usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
{ {
struct usbnet *dev; struct usbnet *dev;
struct net_device *net; struct net_device *net;
struct usb_host_interface *interface; struct usb_host_interface *interface;
struct driver_info *info; struct driver_info *info;
struct usb_device *xdev; struct usb_device *xdev;
...@@ -1181,6 +1181,9 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) ...@@ -1181,6 +1181,9 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
// NOTE net->name still not usable ... // NOTE net->name still not usable ...
if (info->bind) { if (info->bind) {
status = info->bind (dev, udev); status = info->bind (dev, udev);
if (status < 0)
goto out1;
// heuristic: "usb%d" for links we know are two-host, // heuristic: "usb%d" for links we know are two-host,
// else "eth%d" when there's reasonable doubt. userspace // else "eth%d" when there's reasonable doubt. userspace
// can rename the link if it knows better. // can rename the link if it knows better.
...@@ -1207,12 +1210,12 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) ...@@ -1207,12 +1210,12 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
if (status == 0 && dev->status) if (status == 0 && dev->status)
status = init_status (dev, udev); status = init_status (dev, udev);
if (status < 0) if (status < 0)
goto out1; goto out3;
if (!dev->rx_urb_size) if (!dev->rx_urb_size)
dev->rx_urb_size = dev->hard_mtu; dev->rx_urb_size = dev->hard_mtu;
dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1); dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
SET_NETDEV_DEV(net, &udev->dev); SET_NETDEV_DEV(net, &udev->dev);
status = register_netdev (net); status = register_netdev (net);
if (status) if (status)
...@@ -1255,7 +1258,7 @@ EXPORT_SYMBOL_GPL(usbnet_probe); ...@@ -1255,7 +1258,7 @@ EXPORT_SYMBOL_GPL(usbnet_probe);
int usbnet_suspend (struct usb_interface *intf, pm_message_t message) int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
{ {
struct usbnet *dev = usb_get_intfdata(intf); struct usbnet *dev = usb_get_intfdata(intf);
/* accelerate emptying of the rx and queues, to avoid /* accelerate emptying of the rx and queues, to avoid
* having everything error out. * having everything error out.
*/ */
...@@ -1286,7 +1289,7 @@ static int __init usbnet_init(void) ...@@ -1286,7 +1289,7 @@ static int __init usbnet_init(void)
< sizeof (struct skb_data)); < sizeof (struct skb_data));
random_ether_addr(node_id); random_ether_addr(node_id);
return 0; return 0;
} }
module_init(usbnet_init); module_init(usbnet_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment