RE: [PATCH 04/10] usb/gadget: add some infracture to register/unregister functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Sebastian,

Thank you for the patches. By no means am I questioning your work;
I have a question, though. Please see inline.

On Wednesday, October 17, 2012 9:07 PM Sebastian Andrzej Siewior wrote:

<snip>

> +static struct usb_function *try_get_usb_function(const char *name)
> +{
> +	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);

Suppose this executes fine; module refcount is increased.

> +			uf = ERR_PTR(-EBUSY);
> +			if (!ok)
> +				goto out;
> +			uf = f->alloc();

But then suppose this failed

<snip>

> +
> +struct usb_function *usb_get_function(const char *name)
> +{
> +	struct usb_function *uf;
> +	int ret;
> +
> +	uf = try_get_usb_function(name);
> +	if (!IS_ERR(uf))
> +		return uf;
> +	ret = PTR_ERR(uf);
> +	if (ret != -ENOENT)
> +		return uf;
> +	ret = request_module("usbfunc:%s", name);
> +	if (ret < 0)
> +		return ERR_PTR(ret);
> +	return try_get_usb_function(name);
> +}
> +EXPORT_SYMBOL_GPL(usb_get_function);

and, in consequence, usb_get_function returns -ENOMEM.
Which is the hint to the caller that there is no need to call
usb_put_function. And so the module refcount remains increased.

Even if the caller did call usb_put_function, the uf->mod
is not set anyway, so module_put() is not called.

Am I missing something?

Thanks,

AP


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux