Messages in this thread Patch in this message | | | Date | Wed, 9 Aug 2000 13:42:12 -0300 | From | Arnaldo Carvalho de Melo <> | Subject | [PATCH] olympic.c: fixes to olympic_scan |
| |
Hi,
Please take a look and consider applying.
- Arnaldo
--- linux-2.4.0-test6-pre9/drivers/net/tokenring/olympic.c Fri Jul 28 06:34:46 2000 +++ linux-2.4.0-test6-pre9.acme/drivers/net/tokenring/olympic.c Wed Aug 9 13:32:41 2000 @@ -14,6 +14,9 @@ * Thanks to Erik De Cock, Adrian Bridgett and Frank Fiene for their * assistance and perserverance with the testing of this driver. * + * Fixes: + * Arnaldo Carvalho de Melo <acme@conectiva.com.br> (9/8/2000) + * * This software may be used and distributed according to the terms * of the GNU Public License, incorporated herein by reference. * @@ -38,6 +41,8 @@ * Fixing the hardware descriptors was another matter, * because they weren't going through read[wl](), there all * the results had to be in memory in le32 values. kdaaker + * 9/8/00 - check kmalloc and init_trdev in olympic_scan, releasing + * resources on failure. * * * To Do: @@ -177,7 +182,6 @@ struct olympic_private *olympic_priv; int card_no = 0 ; if (pci_present()) { - while((pci_device=pci_find_device(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_TR_WAKE, pci_device))) { __u16 pci_command ; @@ -203,11 +207,18 @@ } olympic_priv=kmalloc(sizeof (struct olympic_private), GFP_KERNEL); + + if (!olympic_priv) + return 0; + memset(olympic_priv, 0, sizeof(struct olympic_private)); init_waitqueue_head(&olympic_priv->srb_wait); init_waitqueue_head(&olympic_priv->trb_wait); #ifndef MODULE dev=init_trdev(dev, 0); + + if (!dev) + goto fail_alloc_dev; #endif dev->priv=(void *)olympic_priv; #if OLYMPIC_DEBUG @@ -230,11 +241,8 @@ olympic_priv->olympic_ring_speed = ringspeed[card_no] ; olympic_priv->olympic_message_level = message_level[card_no] ; - if(olympic_init(dev)==-1) { - unregister_netdevice(dev); - kfree(dev->priv); - return 0; - } + if(olympic_init(dev)==-1) + goto fail_init; dev->open=&olympic_open; dev->hard_start_xmit=&olympic_xmit; @@ -249,6 +257,13 @@ } } return 0 ; + +fail_init: + unregister_netdevice(dev); + kfree(dev); +fail_alloc_dev: + kfree(olympic_priv); + return 0; } ----- End forwarded message ----- --
- Arnaldo
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |