From b333f39b672bcc9639ac406bf4d63f2ea210930f Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Tue, 24 Jun 2025 10:00:33 +0700 Subject: [PATCH] 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 --- lustre/ptlrpc/sec.c | 3 +++ 1 file changed, 3 insertions(+) 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); -- 1.8.3.1