]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
UBI: cleanup usage of try_module_get
authorFernando Luis Vázquez Cao <fernando@oss.ntt.co.jp>
Wed, 11 Jul 2007 08:11:45 +0000 (17:11 +0900)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Wed, 18 Jul 2007 13:58:45 +0000 (16:58 +0300)
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>
drivers/mtd/ubi/kapi.c

index 14c66b48798e2f882f583dc5af38f67916000227..78cae4940875e78232154ae6e05230937cff8194 100644 (file)
@@ -37,12 +37,8 @@ int ubi_get_device_info(int ubi_num, struct ubi_device_info *di)
 {
        const struct ubi_device *ubi;
 
-       if (!try_module_get(THIS_MODULE))
-               return -ENODEV;
-
        if (ubi_num < 0 || ubi_num >= UBI_MAX_DEVICES ||
            !ubi_devices[ubi_num]) {
-               module_put(THIS_MODULE);
                return -ENODEV;
        }
 
@@ -52,7 +48,6 @@ int ubi_get_device_info(int ubi_num, struct ubi_device_info *di)
        di->min_io_size = ubi->min_io_size;
        di->ro_mode = ubi->ro_mode;
        di->cdev = MKDEV(ubi->major, 0);
-       module_put(THIS_MODULE);
        return 0;
 }
 EXPORT_SYMBOL_GPL(ubi_get_device_info);