[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Restore NULL checks before calling kfree().



# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 9ead082168053f8912a902c65e8adb42961ef179
# Parent  3f2751c6e72113d4a985aec3ed232a62bb4429df
Restore NULL checks before calling kfree().
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r 3f2751c6e721 -r 9ead08216805 
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Sat Sep 10 14:44:31 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Sat Sep 10 20:14:50 2005
@@ -48,7 +48,8 @@
        unregister_xenbus_watch(&be->backend_watch);
        if (be->blkif)
                blkif_put(be->blkif);
-       kfree(be->frontpath);
+       if (be->frontpath)
+               kfree(be->frontpath);
        kfree(be);
        return 0;
 }
@@ -254,7 +255,8 @@
  free_be:
        if (be->backend_watch.node)
                unregister_xenbus_watch(&be->backend_watch);
-       kfree(frontend);
+       if (frontend)
+               kfree(frontend);
        kfree(be);
        return err;
 }
diff -r 3f2751c6e721 -r 9ead08216805 
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Sat Sep 10 
14:44:31 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Sat Sep 10 
20:14:50 2005
@@ -608,7 +608,8 @@
        }
 
  out:
-       kfree(backend);
+       if (backend)
+               kfree(backend);
        return err;
 
  abort_transaction:
diff -r 3f2751c6e721 -r 9ead08216805 
linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c  Sat Sep 10 14:44:31 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c  Sat Sep 10 20:14:50 2005
@@ -52,7 +52,8 @@
        unregister_xenbus_watch(&be->backend_watch);
        if (be->blkif)
                blkif_put(be->blkif);
-       kfree(be->frontpath);
+       if (be->frontpath)
+               kfree(be->frontpath);
        kfree(be);
        return 0;
 }
@@ -199,7 +200,8 @@
  free_be:
        if (be->backend_watch.node)
                unregister_xenbus_watch(&be->backend_watch);
-       kfree(frontend);
+       if (frontend)
+               kfree(frontend);
        kfree(be);
        return err;
 }
diff -r 3f2751c6e721 -r 9ead08216805 
linux-2.6-xen-sparse/drivers/xen/netback/loopback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c       Sat Sep 10 
14:44:31 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c       Sat Sep 10 
20:14:50 2005
@@ -160,8 +160,10 @@
        return 0;
 
  fail:
-       kfree(dev1);
-       kfree(dev2);
+       if (dev1 != NULL)
+               kfree(dev1);
+       if (dev2 != NULL)
+               kfree(dev2);
        return err;
 }
 
diff -r 3f2751c6e721 -r 9ead08216805 
linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Sat Sep 10 14:44:31 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Sat Sep 10 20:14:50 2005
@@ -50,7 +50,8 @@
        unregister_xenbus_watch(&be->backend_watch);
        if (be->netif)
                netif_disconnect(be->netif);
-       kfree(be->frontpath);
+       if (be->frontpath)
+               kfree(be->frontpath);
        kfree(be);
        return 0;
 }
@@ -269,7 +270,8 @@
  free_be:
        if (be->backend_watch.node)
                unregister_xenbus_watch(&be->backend_watch);
-       kfree(frontend);
+       if (frontend)
+               kfree(frontend);
        kfree(be);
        return err;
 }
diff -r 3f2751c6e721 -r 9ead08216805 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Sat Sep 10 
14:44:31 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Sat Sep 10 
20:14:50 2005
@@ -1232,7 +1232,8 @@
        netif_state = NETIF_STATE_CONNECTED;
 
  out:
-       kfree(backend);
+       if (backend)
+               kfree(backend);
        return err;
 
  abort_transaction:
diff -r 3f2751c6e721 -r 9ead08216805 
linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c        Sat Sep 10 
14:44:31 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c        Sat Sep 10 
20:14:50 2005
@@ -148,7 +148,9 @@
 packet_free(struct packet *pak)
 {
        del_singleshot_timer_sync(&pak->processing_timer);
-       kfree(pak->data_buffer);
+       if (pak->data_buffer) {
+               kfree(pak->data_buffer);
+       }
        /*
         * cannot do tpmif_put(pak->tpmif); bad things happen
         * on the last tpmif_put()
diff -r 3f2751c6e721 -r 9ead08216805 
linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Sat Sep 10 14:44:31 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Sat Sep 10 20:14:50 2005
@@ -52,7 +52,8 @@
                tpmif_put(be->tpmif);
        }
 
-       kfree(be->frontpath);
+       if (be->frontpath)
+               kfree(be->frontpath);
        kfree(be);
        return 0;
 }
@@ -242,7 +243,8 @@
 free_be:
        if (be->backend_watch.node)
                unregister_xenbus_watch(&be->backend_watch);
-       kfree(frontend);
+       if (frontend)
+               kfree(frontend);
        kfree(be);
        return err;
 }
diff -r 3f2751c6e721 -r 9ead08216805 
linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c      Sat Sep 10 
14:44:31 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c      Sat Sep 10 
20:14:50 2005
@@ -363,7 +363,8 @@
        }
 
 out:
-       kfree(backend);
+       if (backend)
+               kfree(backend);
        return err;
 
 abort_transaction:
diff -r 3f2751c6e721 -r 9ead08216805 
linux-2.6-xen-sparse/drivers/xen/usbback/usbback.c
--- a/linux-2.6-xen-sparse/drivers/xen/usbback/usbback.c        Sat Sep 10 
14:44:31 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback.c        Sat Sep 10 
20:14:50 2005
@@ -781,7 +781,8 @@
     return;
     
  no_mem:
-    kfree(setup);
+    if ( setup != NULL )
+        kfree(setup);
     make_response(up, req->id, req->operation, -ENOMEM, 0, 0);
     return;
 } 
diff -r 3f2751c6e721 -r 9ead08216805 
linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront.c      Sat Sep 10 
14:44:31 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront.c      Sat Sep 10 
20:14:50 2005
@@ -1720,7 +1720,8 @@
        return 0;
 
 up_failed:
-       kfree(errbuf);
+       if (errbuf)
+               kfree(errbuf);
 
 errbuf_failed:
        return retval;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.