diff options
author | Fernando Luis Vázquez Cao <fernando@oss.ntt.co.jp> | 2007-07-11 04:11:45 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-07-18 09:58:45 -0400 |
commit | 2db61c95c03d08bb885c87a816540e75190c924a (patch) | |
tree | 1376072b9ed06ff51e35c50be6fec569ee7a3e61 | |
parent | d08c3b78b8c46a01b8fa59037a0d9fbb777fb465 (diff) |
UBI: cleanup usage of try_module_get
The use of try_module_get(THIS_MODULE) in ubi_get_device_info does not
offer real protection against unexpected driver unloads, since we could
be preempted before try_modules_get gets executed. It is the caller who
should manipulate the refcounts. Besides, ubi_get_device_info is an
exported symbol which guarantees protection when accessed through
symbol_get.
Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r-- | drivers/mtd/ubi/kapi.c | 5 |
1 files changed, 0 insertions, 5 deletions
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c index 14c66b48798e..78cae4940875 100644 --- a/drivers/mtd/ubi/kapi.c +++ b/drivers/mtd/ubi/kapi.c | |||
@@ -37,12 +37,8 @@ int ubi_get_device_info(int ubi_num, struct ubi_device_info *di) | |||
37 | { | 37 | { |
38 | const struct ubi_device *ubi; | 38 | const struct ubi_device *ubi; |
39 | 39 | ||
40 | if (!try_module_get(THIS_MODULE)) | ||
41 | return -ENODEV; | ||
42 | |||
43 | if (ubi_num < 0 || ubi_num >= UBI_MAX_DEVICES || | 40 | if (ubi_num < 0 || ubi_num >= UBI_MAX_DEVICES || |
44 | !ubi_devices[ubi_num]) { | 41 | !ubi_devices[ubi_num]) { |
45 | module_put(THIS_MODULE); | ||
46 | return -ENODEV; | 42 | return -ENODEV; |
47 | } | 43 | } |
48 | 44 | ||
@@ -52,7 +48,6 @@ int ubi_get_device_info(int ubi_num, struct ubi_device_info *di) | |||
52 | di->min_io_size = ubi->min_io_size; | 48 | di->min_io_size = ubi->min_io_size; |
53 | di->ro_mode = ubi->ro_mode; | 49 | di->ro_mode = ubi->ro_mode; |
54 | di->cdev = MKDEV(ubi->major, 0); | 50 | di->cdev = MKDEV(ubi->major, 0); |
55 | module_put(THIS_MODULE); | ||
56 | return 0; | 51 | return 0; |
57 | } | 52 | } |
58 | EXPORT_SYMBOL_GPL(ubi_get_device_info); | 53 | EXPORT_SYMBOL_GPL(ubi_get_device_info); |