[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1184140531.4608.16.camel@sebastian.kern.oss.ntt.co.jp>
Date: Wed, 11 Jul 2007 16:55:31 +0900
From: Fernando Luis Vázquez Cao
<fernando@....ntt.co.jp>
To: Rusty Russell <rusty@...tcorp.com.au>
Cc: dedekind@...radead.org, linux-kernel@...r.kernel.org
Subject: [PATCH RFC] try_module_get usage
I keep seeing uses of try_module_get(THIS_MODULE) which seem to mimic
the behavior of the former MOD_INC_USE_COUNT. The UBI driver is one
example:
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;
}
ubi = ubi_devices[ubi_num];
di->ubi_num = ubi->ubi_num;
di->leb_size = ubi->leb_size;
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;
}
My understanding is that this is not completely safe (we could be
preempted before try_modules_get gets executed) and that it is the
caller who should manipulate the refcounts. Am I missing something here?
Thank you in advance.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists