usb: gadget: f_fs: Stop ffs_closed NULL pointer dereference
authorJim Baxter <jim_baxter@mentor.com>
Thu, 8 Sep 2016 09:18:16 +0000 (11:18 +0200)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 8 Sep 2016 10:53:01 +0000 (13:53 +0300)
The struct ffs_data::private_data has a pointer to
ffs_dev stored in it during the ffs_fs_mount() function
however it is not cleared when the ffs_dev is freed
later which causes the ffs_closed function to crash
with "Unable to handle kernel NULL pointer dereference"
error when using the data in ffs_data::private_data.

This clears this pointer during the ffs_free_dev clean
up function.

Signed-off-by: Jim Baxter <jim_baxter@mentor.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Harish Jenny K N <harish_kandiga@mentor.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/function/f_fs.c

index 998697bd80acd88c8519082dfe3ae1bdff3e9fe6..0aeed85bb5cbbe76c6a9318db9ef1ee7cdd0ca5d 100644 (file)
@@ -3502,6 +3502,11 @@ static void _ffs_free_dev(struct ffs_dev *dev)
        list_del(&dev->entry);
        if (dev->name_allocated)
                kfree(dev->name);
+
+       /* Clear the private_data pointer to stop incorrect dev access */
+       if (dev->ffs_data)
+               dev->ffs_data->private_data = NULL;
+
        kfree(dev);
        if (list_empty(&ffs_devices))
                functionfs_cleanup();
This page took 0.027303 seconds and 5 git commands to generate.