[lkml]   [2022]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRE: [EXT] Re: [PATCH] USB: gadget: Add ID numbers to configfs-gadget driver names
> >
> > Move all free into gadget_info_attr_release(), just before kfree(gi)
> > and gi create at the same place,
> > Free should be the same place also.
> >
> Thanks a lot for the quick review comment.
> As per my observation through the test, on the first mount, the
> virtual-media the gadgets_make() is called, then later, when unmount,
> the gadgets_drop() is called and followed by gadget_info_attr_release().
> The gadget_info_attr_release() is registered as .release() of
> gadget_root_type for the gi->group via the call
> "config_group_init_type_name(&gi->group, name, &gadget_root_type);"
> In general, the .release() will be called only for the group. There is
> nothing to guarantee that the group will always be registered, ie:
> incase without the call to "config_group_init_type_name(&gi->group,
> name, &gadget_root_type);"
> In this patch, what is added is an ida number to be used to make up the
> composite driver name. This is done in gadgets_make() so we'd like to
> add the cleanup code to gadgets_drop() as they are registered together
> in the same place and would be a little easier to read than adding them
> to _release() as the code below:
> static struct configfs_group_operations gadgets_ops = {
> .make_group = &gadgets_make,
> .drop_item = &gadgets_drop,
> };
> Anyway, we still doubt that there might be something that we have missed
> so please let me know the reason why putting cleanup codes to _release()
> would be a better solution.

Let's simply the logic

gi-> = kasprintf();
gi->compositr.gadget_drver.function = kstrdup();

this is only place to create gi and
no other place to set, so I think gi take ownship of

so we only track when gi free, just free before gi free.

Related malloc and free should be pair together.

} should be similar as gadget_driver.function

If is freed in gadget_drop(), gi can not actually be reused again.

> Thank you and best regards,
> - Chanh
> >
> >>>> config_item_put(item);
> >>>> }
> >>>
 \ /
  Last update: 2022-12-15 17:16    [W:0.111 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site