USB: Fix memory leak in mon_stat_release
[deliverable/linux.git] / drivers / usb / mon / mon_stat.c
index 1fe01d994a793f79ec801a663a8ddb1eec54a345..c7a595cd648ae2b2f473390b94d0f89b0fb2214f 100644 (file)
@@ -28,7 +28,7 @@ static int mon_stat_open(struct inode *inode, struct file *file)
        if ((sp = kmalloc(sizeof(struct snap), GFP_KERNEL)) == NULL)
                return -ENOMEM;
 
-       mbus = inode->u.generic_ip;
+       mbus = inode->i_private;
 
        sp->slen = snprintf(sp->str, STAT_BUF_SIZE,
            "nreaders %d events %u text_lost %u\n",
@@ -59,10 +59,13 @@ static ssize_t mon_stat_read(struct file *file, char __user *buf,
 
 static int mon_stat_release(struct inode *inode, struct file *file)
 {
+       struct snap *sp = file->private_data;
+       file->private_data = NULL;
+       kfree(sp);
        return 0;
 }
 
-struct file_operations mon_fops_stat = {
+const struct file_operations mon_fops_stat = {
        .owner =        THIS_MODULE,
        .open =         mon_stat_open,
        .llseek =       no_llseek,
This page took 0.037799 seconds and 5 git commands to generate.