Skip to content

Commit f14e9ad

Browse files
rmsilvaFelipe Balbi
authored andcommitted
usb: gadget: f_fs: add extra check before unregister_gadget_item
ffs_closed can race with configfs_rmdir which will call config_item_release, so add an extra check to avoid calling the unregister_gadget_item with an null gadget item. Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
1 parent 76e838c commit f14e9ad

File tree

1 file changed

+8
-2
lines changed
  • drivers/usb/gadget/function

1 file changed

+8
-2
lines changed

drivers/usb/gadget/function/f_fs.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3433,6 +3433,7 @@ static int ffs_ready(struct ffs_data *ffs)
34333433
static void ffs_closed(struct ffs_data *ffs)
34343434
{
34353435
struct ffs_dev *ffs_obj;
3436+
struct f_fs_opts *opts;
34363437

34373438
ENTER();
34383439
ffs_dev_lock();
@@ -3446,8 +3447,13 @@ static void ffs_closed(struct ffs_data *ffs)
34463447
if (ffs_obj->ffs_closed_callback)
34473448
ffs_obj->ffs_closed_callback(ffs);
34483449

3449-
if (!ffs_obj->opts || ffs_obj->opts->no_configfs
3450-
|| !ffs_obj->opts->func_inst.group.cg_item.ci_parent)
3450+
if (ffs_obj->opts)
3451+
opts = ffs_obj->opts;
3452+
else
3453+
goto done;
3454+
3455+
if (opts->no_configfs || !opts->func_inst.group.cg_item.ci_parent
3456+
|| !atomic_read(&opts->func_inst.group.cg_item.ci_kref.refcount))
34513457
goto done;
34523458

34533459
unregister_gadget_item(ffs_obj->opts->

0 commit comments

Comments
 (0)