From: Shaun Tancheff Date: Tue, 24 Jun 2025 03:00:33 +0000 (+0700) Subject: LU-19122 sec: NULL import should not crash X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=b333f39b672bcc9639ac406bf4d63f2ea210930f;p=fs%2Flustre-release.git LU-19122 sec: NULL import should not crash Protect against NULL imp sptlrpc_import_sec_ref() should return NULL if imp is NULL Existing callers can handle NULL returned from sptlrpc_import_sec_ref() when imp is NULL Signed-off-by: Shaun Tancheff Change-Id: I086cf835de7513f3a15d4ec3e4b907c3c6eae7bd Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59903 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin --- diff --git a/lustre/ptlrpc/sec.c b/lustre/ptlrpc/sec.c index 645010a..2ac473e 100644 --- a/lustre/ptlrpc/sec.c +++ b/lustre/ptlrpc/sec.c @@ -1510,6 +1510,9 @@ struct ptlrpc_sec *sptlrpc_import_sec_ref(struct obd_import *imp) { struct ptlrpc_sec *sec; + if (IS_ERR_OR_NULL(imp)) + return NULL; + read_lock(&imp->imp_sec_lock); sec = sptlrpc_sec_get(imp->imp_sec); read_unlock(&imp->imp_sec_lock);