usb: gadget: ffs: Defer freeing memory on free_inst if in use
In the case of ffs_free_inst() called, whole ffs_dev structure is
freed. Userspace related API do not check if ffs_dev is freed or
not.
If ffs endpoint is opened by userspace, ffs_free_inst() is executed,
mark inst_exist to false but do not free instance structures until
ffs_data is freed.
Besides, ffs_data is allocated in ffs_fs_mount() while opts->dev
is allocated when ffs instance created. And opts->dev will
be freed when ffs instance freed.
If ffs instance is freed and created once, opts->dev is allocated
to new memory, but since ffs_fs_mount() won't be called in this
case, new opts->dev miss the ffs_data address and
ffs_data->private_data still point to old opts->dev address which
is already freed.
So new allocated opts->dev need to initialize opts->dev->ffs_data,
and ffs_private_data also need to update new allocated opts->dev
address.
Change-Id: Idea56f86c62da700926e8ce3a724d5be6295a4fd
Signed-off-by: Liangliang Lu <luliang@codeaurora.org>
Loading
Please register or sign in to comment