On Monday, October 22, 2012 1:03 PM Sebastian Andrzej Siewior wrote:
> * Andrzej Pietrasiewicz | 2012-10-18 13:17:18 [+0200]:
>
> >Hello Sebastian,
> Hi Andrzej,
>
<snip>
>
> This should not happen, I should have put the module.
>
> >Even if the caller did call usb_put_function, the uf->mod is not set
> >anyway, so module_put() is not called.
> >
<snip>
>
> No, thanks for the hint. So with this in my tree
> | {
> | struct usb_d_function *f;
> | struct usb_function *uf;
> |
> | mutex_lock(&func_lock);
> | list_for_each_entry(f, &func_list, list) {
> | if (!strcmp(name, f->name)) {
> | bool ok;
> | ok = try_module_get(f->mod);
> | uf = ERR_PTR(-EBUSY);
> | if (!ok)
> | goto out;
> | uf = f->alloc();
> | if (uf) {
> | uf->mod = f->mod;
> | } else {
> | module_put(f->mod);
> | uf = ERR_PTR(-ENOMEM);
> | }
> | mutex_unlock(&func_lock);
> | return uf;
> | }
> | }
> | uf = ERR_PTR(-ENOENT);
> | out:
> | mutex_unlock(&func_lock);
> | return uf;
> | }
>
> it should be fine, right?
>
Looks good to me.
AP
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html