Merge HEAD from ../scsi-misc-2.6-tmp
[sfrench/cifs-2.6.git] / drivers / scsi / sg.c
index 14fb179b3842193dceacd206b1b22d23d54a324f..052d55c167d41d04a03dac56b3e5d75bfc064db2 100644 (file)
@@ -2970,23 +2970,22 @@ static void * dev_seq_start(struct seq_file *s, loff_t *pos)
 {
        struct sg_proc_deviter * it = kmalloc(sizeof(*it), GFP_KERNEL);
 
+       s->private = it;
        if (! it)
                return NULL;
+
        if (NULL == sg_dev_arr)
-               goto err1;
+               return NULL;
        it->index = *pos;
        it->max = sg_last_dev();
        if (it->index >= it->max)
-               goto err1;
+               return NULL;
        return it;
-err1:
-       kfree(it);
-       return NULL;
 }
 
 static void * dev_seq_next(struct seq_file *s, void *v, loff_t *pos)
 {
-       struct sg_proc_deviter * it = (struct sg_proc_deviter *) v;
+       struct sg_proc_deviter * it = s->private;
 
        *pos = ++it->index;
        return (it->index < it->max) ? it : NULL;
@@ -2994,7 +2993,7 @@ static void * dev_seq_next(struct seq_file *s, void *v, loff_t *pos)
 
 static void dev_seq_stop(struct seq_file *s, void *v)
 {
-       kfree (v);
+       kfree(s->private);
 }
 
 static int sg_proc_open_dev(struct inode *inode, struct file *file)