fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / um / drivers / daemon_user.c
index cf15b4a..310af0f 100644 (file)
@@ -17,6 +17,7 @@
 #include "user_util.h"
 #include "user.h"
 #include "os.h"
+#include "um_malloc.h"
 
 #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER)
 
@@ -98,7 +99,7 @@ static int connect_to_switch(struct daemon_data *pri)
                printk("daemon_open : control setup request failed, err = %d\n",
                       -n);
                err = -ENOTCONN;
-               goto out;               
+               goto out_free;
        }
 
        n = os_read_file(pri->control, sun, sizeof(*sun));
@@ -106,12 +107,14 @@ static int connect_to_switch(struct daemon_data *pri)
                printk("daemon_open : read of data socket failed, err = %d\n",
                       -n);
                err = -ENOTCONN;
-               goto out_close;         
+               goto out_free;
        }
 
        pri->data_addr = sun;
        return(fd);
 
+ out_free:
+       kfree(sun);
  out_close:
        os_close_file(fd);
  out:
@@ -156,10 +159,16 @@ static void daemon_remove(void *data)
        struct daemon_data *pri = data;
 
        os_close_file(pri->fd);
+       pri->fd = -1;
        os_close_file(pri->control);
-       if(pri->data_addr != NULL) kfree(pri->data_addr);
-       if(pri->ctl_addr != NULL) kfree(pri->ctl_addr);
-       if(pri->local_addr != NULL) kfree(pri->local_addr);
+       pri->control = -1;
+
+       kfree(pri->data_addr);
+       pri->data_addr = NULL;
+       kfree(pri->ctl_addr);
+       pri->ctl_addr = NULL;
+       kfree(pri->local_addr);
+       pri->local_addr = NULL;
 }
 
 int daemon_user_write(int fd, void *buf, int len, struct daemon_data *pri)
@@ -174,7 +183,7 @@ static int daemon_set_mtu(int mtu, void *data)
        return(mtu);
 }
 
-struct net_user_info daemon_user_info = {
+const struct net_user_info daemon_user_info = {
        .init           = daemon_user_init,
        .open           = daemon_open,
        .close          = NULL,