diff options
author | David Brownell <david-b@pacbell.net> | 2007-02-15 21:52:30 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-02-16 18:32:22 -0500 |
commit | cb1cebbee61abcb6b55c63fdfebb5ca5effaedea (patch) | |
tree | 15b2d33ba284bff9dcbf3aa87c23c289f9dc095c /drivers/usb/net | |
parent | 6e91f527cd0644530894ee3bfb06d209d3c8c54a (diff) |
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: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/net')
-rw-r--r-- | drivers/usb/net/usbnet.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 43ba61abfcc5..de69b183bd2f 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c | |||
@@ -147,7 +147,7 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf) | |||
147 | if (tmp < 0) | 147 | if (tmp < 0) |
148 | return tmp; | 148 | return tmp; |
149 | } | 149 | } |
150 | 150 | ||
151 | dev->in = usb_rcvbulkpipe (dev->udev, | 151 | dev->in = usb_rcvbulkpipe (dev->udev, |
152 | in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); | 152 | in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); |
153 | dev->out = usb_sndbulkpipe (dev->udev, | 153 | dev->out = usb_sndbulkpipe (dev->udev, |
@@ -327,7 +327,7 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags) | |||
327 | if (netif_running (dev->net) | 327 | if (netif_running (dev->net) |
328 | && netif_device_present (dev->net) | 328 | && netif_device_present (dev->net) |
329 | && !test_bit (EVENT_RX_HALT, &dev->flags)) { | 329 | && !test_bit (EVENT_RX_HALT, &dev->flags)) { |
330 | switch (retval = usb_submit_urb (urb, GFP_ATOMIC)){ | 330 | switch (retval = usb_submit_urb (urb, GFP_ATOMIC)){ |
331 | case -EPIPE: | 331 | case -EPIPE: |
332 | usbnet_defer_kevent (dev, EVENT_RX_HALT); | 332 | usbnet_defer_kevent (dev, EVENT_RX_HALT); |
333 | break; | 333 | break; |
@@ -443,7 +443,7 @@ block: | |||
443 | case -EOVERFLOW: | 443 | case -EOVERFLOW: |
444 | dev->stats.rx_over_errors++; | 444 | dev->stats.rx_over_errors++; |
445 | // FALLTHROUGH | 445 | // FALLTHROUGH |
446 | 446 | ||
447 | default: | 447 | default: |
448 | entry->state = rx_cleanup; | 448 | entry->state = rx_cleanup; |
449 | dev->stats.rx_errors++; | 449 | dev->stats.rx_errors++; |
@@ -560,7 +560,7 @@ static int usbnet_stop (struct net_device *net) | |||
560 | 560 | ||
561 | if (netif_msg_ifdown (dev)) | 561 | if (netif_msg_ifdown (dev)) |
562 | devinfo (dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld", | 562 | devinfo (dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld", |
563 | dev->stats.rx_packets, dev->stats.tx_packets, | 563 | dev->stats.rx_packets, dev->stats.tx_packets, |
564 | dev->stats.rx_errors, dev->stats.tx_errors | 564 | dev->stats.rx_errors, dev->stats.tx_errors |
565 | ); | 565 | ); |
566 | 566 | ||
@@ -578,7 +578,7 @@ static int usbnet_stop (struct net_device *net) | |||
578 | devdbg (dev, "waited for %d urb completions", temp); | 578 | devdbg (dev, "waited for %d urb completions", temp); |
579 | } | 579 | } |
580 | dev->wait = NULL; | 580 | dev->wait = NULL; |
581 | remove_wait_queue (&unlink_wakeup, &wait); | 581 | remove_wait_queue (&unlink_wakeup, &wait); |
582 | 582 | ||
583 | usb_kill_urb(dev->interrupt); | 583 | usb_kill_urb(dev->interrupt); |
584 | 584 | ||
@@ -834,7 +834,7 @@ kevent (struct work_struct *work) | |||
834 | } | 834 | } |
835 | 835 | ||
836 | if (test_bit (EVENT_LINK_RESET, &dev->flags)) { | 836 | if (test_bit (EVENT_LINK_RESET, &dev->flags)) { |
837 | struct driver_info *info = dev->driver_info; | 837 | struct driver_info *info = dev->driver_info; |
838 | int retval = 0; | 838 | int retval = 0; |
839 | 839 | ||
840 | clear_bit (EVENT_LINK_RESET, &dev->flags); | 840 | clear_bit (EVENT_LINK_RESET, &dev->flags); |
@@ -1066,7 +1066,7 @@ static void usbnet_bh (unsigned long param) | |||
1066 | * USB Device Driver support | 1066 | * USB Device Driver support |
1067 | * | 1067 | * |
1068 | *-------------------------------------------------------------------------*/ | 1068 | *-------------------------------------------------------------------------*/ |
1069 | 1069 | ||
1070 | // precondition: never called in_interrupt | 1070 | // precondition: never called in_interrupt |
1071 | 1071 | ||
1072 | void usbnet_disconnect (struct usb_interface *intf) | 1072 | void usbnet_disconnect (struct usb_interface *intf) |
@@ -1087,7 +1087,7 @@ void usbnet_disconnect (struct usb_interface *intf) | |||
1087 | intf->dev.driver->name, | 1087 | intf->dev.driver->name, |
1088 | xdev->bus->bus_name, xdev->devpath, | 1088 | xdev->bus->bus_name, xdev->devpath, |
1089 | dev->driver_info->description); | 1089 | dev->driver_info->description); |
1090 | 1090 | ||
1091 | net = dev->net; | 1091 | net = dev->net; |
1092 | unregister_netdev (net); | 1092 | unregister_netdev (net); |
1093 | 1093 | ||
@@ -1111,7 +1111,7 @@ int | |||
1111 | usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) | 1111 | usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) |
1112 | { | 1112 | { |
1113 | struct usbnet *dev; | 1113 | struct usbnet *dev; |
1114 | struct net_device *net; | 1114 | struct net_device *net; |
1115 | struct usb_host_interface *interface; | 1115 | struct usb_host_interface *interface; |
1116 | struct driver_info *info; | 1116 | struct driver_info *info; |
1117 | struct usb_device *xdev; | 1117 | struct usb_device *xdev; |
@@ -1181,6 +1181,9 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) | |||
1181 | // NOTE net->name still not usable ... | 1181 | // NOTE net->name still not usable ... |
1182 | if (info->bind) { | 1182 | if (info->bind) { |
1183 | status = info->bind (dev, udev); | 1183 | status = info->bind (dev, udev); |
1184 | if (status < 0) | ||
1185 | goto out1; | ||
1186 | |||
1184 | // heuristic: "usb%d" for links we know are two-host, | 1187 | // heuristic: "usb%d" for links we know are two-host, |
1185 | // else "eth%d" when there's reasonable doubt. userspace | 1188 | // else "eth%d" when there's reasonable doubt. userspace |
1186 | // can rename the link if it knows better. | 1189 | // 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 | if (status == 0 && dev->status) | 1210 | if (status == 0 && dev->status) |
1208 | status = init_status (dev, udev); | 1211 | status = init_status (dev, udev); |
1209 | if (status < 0) | 1212 | if (status < 0) |
1210 | goto out1; | 1213 | goto out3; |
1211 | 1214 | ||
1212 | if (!dev->rx_urb_size) | 1215 | if (!dev->rx_urb_size) |
1213 | dev->rx_urb_size = dev->hard_mtu; | 1216 | dev->rx_urb_size = dev->hard_mtu; |
1214 | dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1); | 1217 | dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1); |
1215 | 1218 | ||
1216 | SET_NETDEV_DEV(net, &udev->dev); | 1219 | SET_NETDEV_DEV(net, &udev->dev); |
1217 | status = register_netdev (net); | 1220 | status = register_netdev (net); |
1218 | if (status) | 1221 | if (status) |
@@ -1255,7 +1258,7 @@ EXPORT_SYMBOL_GPL(usbnet_probe); | |||
1255 | int usbnet_suspend (struct usb_interface *intf, pm_message_t message) | 1258 | int usbnet_suspend (struct usb_interface *intf, pm_message_t message) |
1256 | { | 1259 | { |
1257 | struct usbnet *dev = usb_get_intfdata(intf); | 1260 | struct usbnet *dev = usb_get_intfdata(intf); |
1258 | 1261 | ||
1259 | /* accelerate emptying of the rx and queues, to avoid | 1262 | /* accelerate emptying of the rx and queues, to avoid |
1260 | * having everything error out. | 1263 | * having everything error out. |
1261 | */ | 1264 | */ |
@@ -1286,7 +1289,7 @@ static int __init usbnet_init(void) | |||
1286 | < sizeof (struct skb_data)); | 1289 | < sizeof (struct skb_data)); |
1287 | 1290 | ||
1288 | random_ether_addr(node_id); | 1291 | random_ether_addr(node_id); |
1289 | return 0; | 1292 | return 0; |
1290 | } | 1293 | } |
1291 | module_init(usbnet_init); | 1294 | module_init(usbnet_init); |
1292 | 1295 | ||