[lustre-devel] [PATCH 568/622] lnet: always check return of try_module_get()

James Simmons jsimmons at infradead.org
Thu Feb 27 13:17:16 PST 2020


From: Mr NeilBrown <neilb at suse.de>

try_module_get() can fail, so the return value should be checked.
If we *know* that we already hold a reference, __module_get()
should be used instead.

WC-bug-id: https://jira.whamcloud.com/browse/LU-9679
Lustre-commit: a1282a0d8a53 ("LU-9679 lnet: always check return of try_module_get()")
Signed-off-by: Mr NeilBrown <neilb at suse.de>
Reviewed-on: https://review.whamcloud.com/36854
Reviewed-by: James Simmons <jsimmons at infradead.org>
Reviewed-by: Chris Horn <hornc at cray.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 net/lnet/klnds/o2iblnd/o2iblnd.c | 4 +++-
 net/lnet/klnds/socklnd/socklnd.c | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/lnet/klnds/o2iblnd/o2iblnd.c b/net/lnet/klnds/o2iblnd/o2iblnd.c
index 37d8235..f6db2c7 100644
--- a/net/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/net/lnet/klnds/o2iblnd/o2iblnd.c
@@ -2693,7 +2693,9 @@ static int kiblnd_base_startup(struct net *ns)
 
 	LASSERT(kiblnd_data.kib_init == IBLND_INIT_NOTHING);
 
-	try_module_get(THIS_MODULE);
+	if (!try_module_get(THIS_MODULE))
+		goto failed;
+
 	/* zero pointers, flags etc */
 	memset(&kiblnd_data, 0, sizeof(kiblnd_data));
 
diff --git a/net/lnet/klnds/socklnd/socklnd.c b/net/lnet/klnds/socklnd/socklnd.c
index 593c205..9a19a3f 100644
--- a/net/lnet/klnds/socklnd/socklnd.c
+++ b/net/lnet/klnds/socklnd/socklnd.c
@@ -2357,7 +2357,8 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id)
 
 	/* flag lists/ptrs/locks initialised */
 	ksocknal_data.ksnd_init = SOCKNAL_INIT_DATA;
-	try_module_get(THIS_MODULE);
+	if (!try_module_get(THIS_MODULE))
+		goto failed;
 
 	/* Create a scheduler block per available CPT */
 	ksocknal_data.ksnd_schedulers = cfs_percpt_alloc(lnet_cpt_table(),
-- 
1.8.3.1



More information about the lustre-devel mailing list