From: Akinobu Mita <akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Akinobu Mita
<akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Matthew Dharm
<mdharm-usb-JGfshJpz5UybPZpvUQj5UqxOck334EZe@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
Alan Stern
<stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>,
Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>,
"James E.J. Bottomley"
<JBottomley-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
usb-storage-ijkIwGHArpdIPJnuZ7Njw4oP9KaGy4wf@public.gmane.org
Subject: [PATCH v6 3/4] usb: storage: adjust module reference for scsi host
Date: Mon, 4 May 2015 23:46:08 +0900 [thread overview]
Message-ID: <1430750769-11405-4-git-send-email-akinobu.mita@gmail.com> (raw)
In-Reply-To: <1430750769-11405-1-git-send-email-akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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 passing correct module reference to usb_stor_probe1() so
that .module field in struct Scsi_Host can be adjusted.
Signed-off-by: Akinobu Mita <akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Acked-by: Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>
Cc: Matthew Dharm <mdharm-usb-JGfshJpz5UybPZpvUQj5UqxOck334EZe@public.gmane.org>
Cc: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
Cc: Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>
Cc: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Cc: "James E.J. Bottomley" <JBottomley-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: usb-storage-ijkIwGHArpdIPJnuZ7Njw4oP9KaGy4wf@public.gmane.org
Cc: linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
drivers/usb/storage/usb.c | 8 +++++---
drivers/usb/storage/usb.h | 7 +++++--
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 6c10c88..711cdee 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -921,10 +921,11 @@ static unsigned int usb_stor_sg_tablesize(struct usb_interface *intf)
}
/* First part of general USB mass-storage probing */
-int usb_stor_probe1(struct us_data **pus,
+int __usb_stor_probe1(struct us_data **pus,
struct usb_interface *intf,
const struct usb_device_id *id,
- struct us_unusual_dev *unusual_dev)
+ struct us_unusual_dev *unusual_dev,
+ struct module *owner)
{
struct Scsi_Host *host;
struct us_data *us;
@@ -947,6 +948,7 @@ int usb_stor_probe1(struct us_data **pus,
*/
host->max_cmd_len = 16;
host->sg_tablesize = usb_stor_sg_tablesize(intf);
+ host->module = owner;
*pus = us = host_to_us(host);
mutex_init(&(us->dev_mutex));
us_set_lock_class(&us->dev_mutex, intf);
@@ -979,7 +981,7 @@ BadDevice:
release_everything(us);
return result;
}
-EXPORT_SYMBOL_GPL(usb_stor_probe1);
+EXPORT_SYMBOL_GPL(__usb_stor_probe1);
/* Second part of general USB mass-storage probing */
int usb_stor_probe2(struct us_data *us)
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 307e339..0cb74ba 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -194,10 +194,13 @@ extern int usb_stor_reset_resume(struct usb_interface *iface);
extern int usb_stor_pre_reset(struct usb_interface *iface);
extern int usb_stor_post_reset(struct usb_interface *iface);
-extern int usb_stor_probe1(struct us_data **pus,
+extern int __usb_stor_probe1(struct us_data **pus,
struct usb_interface *intf,
const struct usb_device_id *id,
- struct us_unusual_dev *unusual_dev);
+ struct us_unusual_dev *unusual_dev,
+ struct module *owner);
+#define usb_stor_probe1(pus, intf, id, unusual_dev) \
+ __usb_stor_probe1(pus, intf, id, unusual_dev, THIS_MODULE)
extern int usb_stor_probe2(struct us_data *us);
extern void usb_stor_disconnect(struct usb_interface *intf);
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-05-04 14:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-04 14:46 [PATCH v6 0/4] scsi: ufs & ums-* & esp_scsi: fix module reference counting Akinobu Mita
2015-05-04 14:46 ` [PATCH v6 1/4] scsi: add ability to adjust module reference for scsi host Akinobu Mita
2015-05-04 14:46 ` [PATCH v6 2/4] scsi: ufs: " Akinobu Mita
[not found] ` <1430750769-11405-1-git-send-email-akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-04 14:46 ` Akinobu Mita [this message]
2015-05-04 14:46 ` [PATCH v6 4/4] scsi: esp_scsi: " Akinobu Mita
2015-05-04 15:15 ` [PATCH v6 0/4] scsi: ufs & ums-* & esp_scsi: fix module reference counting James Bottomley
[not found] ` <1430752523.2177.15.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2015-05-04 15:30 ` Hannes Reinecke
2015-05-04 20:09 ` Alan Stern
2015-05-04 21:41 ` James Bottomley
[not found] ` <1430775664.2177.36.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2015-05-05 13:39 ` Akinobu Mita
2015-05-05 15:35 ` James Bottomley
2015-05-05 14:25 ` Alan Stern
2015-05-05 18:05 ` James Bottomley
2015-05-05 19:14 ` Alan Stern
2015-05-05 21:42 ` James Bottomley
2015-05-06 9:26 ` Akinobu Mita
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1430750769-11405-4-git-send-email-akinobu.mita@gmail.com \
--to=akinobu.mita-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=JBottomley-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=hch-jcswGhMUV9g@public.gmane.org \
--cc=linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mdharm-usb-JGfshJpz5UybPZpvUQj5UqxOck334EZe@public.gmane.org \
--cc=stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org \
--cc=usb-storage-ijkIwGHArpdIPJnuZ7Njw4oP9KaGy4wf@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox