patch-1.3.25 linux/drivers/net/eql.c

Next file: linux/drivers/net/ewrk3.c
Previous file: linux/drivers/net/eexpress.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.24/linux/drivers/net/eql.c linux/drivers/net/eql.c
@@ -219,10 +219,17 @@
 
   /* Initialize the device structure. */
   dev->priv = kmalloc (sizeof (equalizer_t), GFP_KERNEL);
+  if (dev->priv == NULL)
+      return -ENOMEM;
   memset (dev->priv, 0, sizeof (equalizer_t));
   eql = (equalizer_t *) dev->priv;
 
   eql->stats = kmalloc (sizeof (struct enet_statistics), GFP_KERNEL);
+  if (eql->stats == NULL) {
+      kfree(dev->priv);
+      dev->priv = NULL;
+      return -ENOMEM;
+  }
   memset (eql->stats, 0, sizeof (struct enet_statistics));
 
   init_timer (&eql->timer);
@@ -761,6 +768,8 @@
   slave_t *tail_slave;
 
   queue = (slave_queue_t *) kmalloc (sizeof (slave_queue_t), GFP_KERNEL);
+  if (queue == NULL)
+    return 0;
   memset (queue, 0, sizeof (slave_queue_t));
 
   head_slave = eql_new_slave ();
@@ -777,6 +786,10 @@
     }
   else
     {
+      if (head_slave)
+         kfree(head_slave);
+      if (tail_slave)
+         kfree(tail_slave);
       kfree (queue);
       return 0;
     }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this