Re: [PATCH 3/3] usb: storage: adjust module reference for scsi host

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

 



On Mon, 5 Jan 2015, Akinobu Mita wrote:

> While accessing a unusual usb storage (ums-alauda, ums-cypress, ...),
> the module reference count is not incremented.  Because these drivers
> allocate scsi hosts with usb_stor_host_template defined in usb-storage
> module.  So these drivers always can be unloaded.
> 
> This fixes it by adjusting module reference after scsi host allocation.

> diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c
> index 62c2d9d..77660d6 100644
> --- a/drivers/usb/storage/alauda.c
> +++ b/drivers/usb/storage/alauda.c
> @@ -1242,6 +1242,7 @@ static int alauda_probe(struct usb_interface *intf,
>  	us->transport = alauda_transport;
>  	us->transport_reset = usb_stor_Bulk_reset;
>  	us->max_lun = 1;
> +	us_to_host(us)->module = THIS_MODULE;
>  
>  	result = usb_stor_probe2(us);
>  	return result;

... etc.

An easier and more foolproof approach would be to change
usb_store_probe2 to take an extra argument for the owner:

int _usb_stor_probe2(struct us_data *us, struct module *owner)
...
	us_to_host(us)->module = owner;
...

Then in usb.h:

extern int _usb_stor_probe2(struct us_data *us, struct module *owner);
#define usb_stor_probe2(us)	_usb_stor_probe2(us, THIS_MODULE)

This pattern is already used in several other places in the kernel.

Alan Stern

--
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