lkml.org 
[lkml]   [2022]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] USB: gadget: Add ID numbers to configfs-gadget driver names
On Wed, Dec 14, 2022 at 11:15:48AM +0700, Chanh Nguyen wrote:

> Thanks CJ for the review!
>
> I've made some changes as below (in gadgets_make() to remove unnecessary
> variables) and now trying to test it as much as possible. Will re-post it as
> v2 if looks good soon.
>
> static inline struct gadget_info *to_gadget_info(struct config_item *item)
> @@ -1623,13 +1629,25 @@ static struct config_group *gadgets_make(
>
> gi->composite.gadget_driver = configfs_driver_template;
>
> + gi->driver_id_number = ida_alloc(&driver_id_numbers, GFP_KERNEL);
> + if (gi->driver_id_number < 0)
> + goto err;
> +
> + gi->composite.gadget_driver.driver.name =
> + kasprintf(GFP_KERNEL, "configfs-gadget.%d",
> + gi->driver_id_number);
> + if (!gi->composite.gadget_driver.driver.name)
> + goto out_free_driver_id_number;
> +
> gi->composite.gadget_driver.function = kstrdup(name, GFP_KERNEL);
> gi->composite.name = gi->composite.gadget_driver.function;
>
> if (!gi->composite.gadget_driver.function)
> - goto err;
> + goto out_free_driver_id_number;

This should goto out_free_driver_name.

Alan Stern

>
> return &gi->group;
> +
> +out_free_driver_id_number:
> + ida_free(&driver_id_numbers, gi->driver_id_number);
> err:
> kfree(gi);
> return ERR_PTR(-ENOMEM);

\
 
 \ /
  Last update: 2022-12-14 16:26    [W:0.101 / U:0.760 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site