Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e42e641 authored by Hemant Kumar's avatar Hemant Kumar Committed by Mayank Rana
Browse files

usb: gadget: f_fs: Unlock mutex before unregistering gadget



Release the lock before unregistering gadget item.
Unregistered gadget item will result in unbind call back
to the driver which may use the same lock and resulting
in deadlock condition.

Change-Id: I2f8fba73a831d3bb711fe9310c5758221359819e
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent de406b7f
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -4034,8 +4034,10 @@ static void ffs_closed(struct ffs_data *ffs)
	ffs_dev_lock();

	ffs_obj = ffs->private_data;
	if (!ffs_obj)
	if (!ffs_obj) {
		ffs_dev_unlock();
		goto done;
	}

	ffs_obj->desc_ready = false;

@@ -4043,22 +4045,26 @@ static void ffs_closed(struct ffs_data *ffs)
	    ffs_obj->ffs_closed_callback)
		ffs_obj->ffs_closed_callback(ffs);

	if (ffs_obj->opts)
	if (ffs_obj->opts) {
		opts = ffs_obj->opts;
	else
	} else {
		ffs_dev_unlock();
		goto done;
	}

	if (opts->no_configfs || !opts->func_inst.group.cg_item.ci_parent
	    || !atomic_read(&opts->func_inst.group.cg_item.ci_kref.refcount))
	    || !atomic_read(&opts->func_inst.group.cg_item.ci_kref.refcount)) {
		ffs_dev_unlock();
		goto done;
	}

	ffs_dev_unlock();

	unregister_gadget_item(ffs_obj->opts->
	unregister_gadget_item(opts->
			       func_inst.group.cg_item.ci_parent->ci_parent);

	ffs_log("unreg gadget done");
done:
	ffs_dev_unlock();

	ffs_log("exit");
}