Whamcloud - gitweb
LU-19122 sec: NULL import should not crash 03/59903/2
authorShaun Tancheff <shaun.tancheff@hpe.com>
Tue, 24 Jun 2025 03:00:33 +0000 (10:00 +0700)
committerOleg Drokin <green@whamcloud.com>
Tue, 8 Jul 2025 03:59:36 +0000 (03:59 +0000)
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 <shaun.tancheff@hpe.com>
Change-Id: I086cf835de7513f3a15d4ec3e4b907c3c6eae7bd
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59903
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ptlrpc/sec.c

index 645010a..2ac473e 100644 (file)
@@ -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);