public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: lustre: add error handling for try_module_get
@ 2018-06-12  4:49 Zhouyang Jia
  2018-06-12  5:26 ` NeilBrown
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Zhouyang Jia @ 2018-06-12  4:49 UTC (permalink / raw)
  Cc: Zhouyang Jia, Oleg Drokin, Andreas Dilger, James Simmons,
	Greg Kroah-Hartman, NeilBrown, Haneen Mohammed, Al Viro,
	Gustavo A. R. Silva, lustre-devel, devel, linux-kernel

When try_module_get fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling try_module_get.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
 drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 7086678..72a42bd 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -2422,7 +2422,10 @@ ksocknal_base_startup(void)
 
 	/* flag lists/ptrs/locks initialised */
 	ksocknal_data.ksnd_init = SOCKNAL_INIT_DATA;
-	try_module_get(THIS_MODULE);
+	if (!try_module_get(THIS_MODULE)) {
+		CERROR("%s: cannot get module\n", __func__);
+		goto failed;
+	}
 
 	ksocknal_data.ksnd_sched_info = cfs_percpt_alloc(lnet_cpt_table(),
 							 sizeof(*info));
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-06-13 12:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-12  4:49 [PATCH] staging: lustre: add error handling for try_module_get Zhouyang Jia
2018-06-12  5:26 ` NeilBrown
2018-06-12  6:31 ` Greg Kroah-Hartman
2018-06-13 10:53 ` David Laight
2018-06-13 12:02   ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox