Skip to content

Commit 3262ad8

Browse files
Jim BaxterFelipe Balbi
authored andcommitted
usb: gadget: f_fs: Stop ffs_closed NULL pointer dereference
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>
1 parent 9d6173e commit 3262ad8

File tree

1 file changed

+5
-0
lines changed
  • drivers/usb/gadget/function

1 file changed

+5
-0
lines changed

drivers/usb/gadget/function/f_fs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3502,6 +3502,11 @@ static void _ffs_free_dev(struct ffs_dev *dev)
35023502
list_del(&dev->entry);
35033503
if (dev->name_allocated)
35043504
kfree(dev->name);
3505+
3506+
/* Clear the private_data pointer to stop incorrect dev access */
3507+
if (dev->ffs_data)
3508+
dev->ffs_data->private_data = NULL;
3509+
35053510
kfree(dev);
35063511
if (list_empty(&ffs_devices))
35073512
functionfs_cleanup();

0 commit comments

Comments
 (0)