[PATCH] uml: const more data
[linux-2.6-microblaze.git] / arch / um / drivers / daemon_user.c
index c1b03f7..77954ea 100644 (file)
@@ -98,7 +98,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 +106,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 +158,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);
+       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 +182,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,