Skip to content

Commit 2db61c9

Browse files
Fernando Luis Vázquez CaoArtem Bityutskiy
authored andcommitted
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 <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]>
1 parent d08c3b7 commit 2db61c9

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

drivers/mtd/ubi/kapi.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,8 @@ int ubi_get_device_info(int ubi_num, struct ubi_device_info *di)
3737
{
3838
const struct ubi_device *ubi;
3939

40-
if (!try_module_get(THIS_MODULE))
41-
return -ENODEV;
42-
4340
if (ubi_num < 0 || ubi_num >= UBI_MAX_DEVICES ||
4441
!ubi_devices[ubi_num]) {
45-
module_put(THIS_MODULE);
4642
return -ENODEV;
4743
}
4844

@@ -52,7 +48,6 @@ int ubi_get_device_info(int ubi_num, struct ubi_device_info *di)
5248
di->min_io_size = ubi->min_io_size;
5349
di->ro_mode = ubi->ro_mode;
5450
di->cdev = MKDEV(ubi->major, 0);
55-
module_put(THIS_MODULE);
5651
return 0;
5752
}
5853
EXPORT_SYMBOL_GPL(ubi_get_device_info);

0 commit comments

Comments
 (0)