ia64/xen-unstable

changeset 504:aeb88ca14b2d

bitkeeper revision 1.273 (3f0575edFviTLBBDDlG_cQyIl8rpIQ)

Fix a small memory leak.
author sos22@labyrinth.cl.cam.ac.uk
date Fri Jul 04 12:41:17 2003 +0000 (2003-07-04)
parents 6be2874c3f07
children 08e3ab6bded3
files xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_segment_proc.c
line diff
     1.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_segment_proc.c	Fri Jul 04 11:46:47 2003 +0000
     1.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_segment_proc.c	Fri Jul 04 12:41:17 2003 +0000
     1.3 @@ -78,33 +78,39 @@ static int proc_write_vhd(struct file *f
     1.4      char *string;
     1.5      int loop;
     1.6      xv_disk_t xvd;
     1.7 +    int res;
     1.8 +
     1.9 +    if (!local)
    1.10 +      return -ENOMEM;
    1.11  
    1.12      memset (&xvd, 0, sizeof(xvd));
    1.13  
    1.14      if (copy_from_user(local, buffer, count))
    1.15      {
    1.16 -        return -EFAULT;
    1.17 +	res = -EFAULT;
    1.18 +	goto out;
    1.19      }
    1.20      local[count] = '\0';
    1.21  
    1.22 +    res = count;
    1.23      string = get_string(local); /* domain specifier */
    1.24      if (string == NULL)
    1.25      {
    1.26 -        return count;
    1.27 +	goto out;
    1.28      }
    1.29      if (*string != 'd' && *string != 'D')
    1.30      {
    1.31          printk (KERN_ALERT 
    1.32                  "error: domain specifier missing [%s]. should be \"domain\".\n",
    1.33                  string);
    1.34 -        return count;
    1.35 +	goto out;
    1.36      }
    1.37  
    1.38      string = get_string(NULL); /* domain number */
    1.39      if (string == NULL)
    1.40      {
    1.41          printk (KERN_ALERT "error: domain number missing\n");
    1.42 -        return count;
    1.43 +	goto out;
    1.44      }
    1.45      xvd.domain = (int) to_number(string);
    1.46  
    1.47 @@ -122,7 +128,7 @@ static int proc_write_vhd(struct file *f
    1.48          printk (KERN_ALERT 
    1.49                  "error: bad mode [%s]. should be \"rw\" or \"ro\".\n",
    1.50                  string);
    1.51 -        return count;
    1.52 +	goto out;
    1.53      }
    1.54  
    1.55      string = get_string(NULL);                           /* look for Segment */
    1.56 @@ -131,14 +137,14 @@ static int proc_write_vhd(struct file *f
    1.57          printk (KERN_ALERT 
    1.58                  "error: segment specifier missing [%s]. should be \"segment\".\n",
    1.59                  string);
    1.60 -        return count;
    1.61 +	goto out;
    1.62      }
    1.63  
    1.64      string = get_string(NULL);                             /* segment number */
    1.65      if (string == NULL)
    1.66      {
    1.67          printk (KERN_ALERT "error: segment number missing\n");
    1.68 -        return count;
    1.69 +	goto out;
    1.70      }
    1.71      xvd.segment = (int) to_number(string);
    1.72  
    1.73 @@ -148,14 +154,14 @@ static int proc_write_vhd(struct file *f
    1.74          printk (KERN_ALERT 
    1.75                  "error: extents specifier missing [%s]. should be \"extents\".\n",
    1.76                  string);
    1.77 -        return count;
    1.78 +	goto out;
    1.79      }
    1.80  
    1.81      string = get_string(NULL);                          /* number of extents */
    1.82      if (string == NULL)
    1.83      {
    1.84          printk (KERN_ALERT "error: number of extents missing\n");
    1.85 -        return count;
    1.86 +	goto out;
    1.87      }
    1.88      xvd.ext_count = (int) to_number(string);
    1.89  
    1.90 @@ -169,13 +175,13 @@ static int proc_write_vhd(struct file *f
    1.91              printk (KERN_ALERT 
    1.92                      "hmm, extent disk specifier missing [%s]. should be \"disk\".\n",
    1.93                      string);
    1.94 -            return count;
    1.95 +	    goto out;
    1.96          }
    1.97          string = get_string(NULL);                            /* disk number */
    1.98          if (string == NULL)
    1.99          {
   1.100              printk (KERN_ALERT "error: disk number missing\n");
   1.101 -            return count;
   1.102 +	    goto out;
   1.103          }
   1.104          xvd.extents[loop].disk = xldev_to_physdev((int) to_number(string));
   1.105  
   1.106 @@ -185,13 +191,13 @@ static int proc_write_vhd(struct file *f
   1.107              printk (KERN_ALERT 
   1.108                      "error: disk offset missing [%s]. should be \"offset\".\n",
   1.109                      string);
   1.110 -            return count;
   1.111 +	    goto out;
   1.112          }
   1.113          string = get_string(NULL);                                 /* offset */
   1.114          if (string == NULL)
   1.115          {
   1.116              printk (KERN_ALERT "error: offset missing\n");
   1.117 -            return count;
   1.118 +	    goto out;
   1.119          }
   1.120          xvd.extents[loop].offset =  to_number(string);
   1.121  
   1.122 @@ -201,20 +207,23 @@ static int proc_write_vhd(struct file *f
   1.123              printk (KERN_ALERT 
   1.124                      "error: extent size missing [%s]. should be \"size\".\n",
   1.125                      string);
   1.126 -            return count;
   1.127 +	    goto out;
   1.128          }
   1.129          string = get_string(NULL);                                   /* size */
   1.130          if (string == NULL)
   1.131          {
   1.132              printk (KERN_ALERT "error: extent size missing\n");
   1.133 -            return count;
   1.134 +	    goto out;
   1.135          }
   1.136          xvd.extents[loop].size =  to_number(string);
   1.137      }
   1.138  
   1.139      xenolinux_control_msg(XEN_BLOCK_SEG_CREATE, (char *)&xvd, sizeof(xvd));
   1.140  
   1.141 -    return count;
   1.142 + out:
   1.143 +    kfree(local);
   1.144 +
   1.145 +    return res;
   1.146  }
   1.147  
   1.148  /******************************************************************/