From f96ee06d926de5b0a797daa03d78ab2faf1f80eb Mon Sep 17 00:00:00 2001 From: Rajeev Mishra Date: Mon, 6 May 2024 20:12:54 +0000 Subject: [PATCH] LU-17817 llapi: avoid potential NULL component Avoid potential NULL dereference for component issue in llapi_layout_file_open() and llapi_layout_file_comp_add() CoverityID: 425352 ("Dereferencing 'comp', which is known to be NULL") HPE-bug-id: LUS-12326 Signed-off-by: Rajeev Mishra Change-Id: Id773fdbf031a2d11256140590f570f90da46ec3a Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55028 Reviewed-by: Arshad Hussain Reviewed-by: Shaun Tancheff Reviewed-by: Petros Koutoupis Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo --- lustre/utils/liblustreapi_layout.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lustre/utils/liblustreapi_layout.c b/lustre/utils/liblustreapi_layout.c index 310d283..bd2a055 100644 --- a/lustre/utils/liblustreapi_layout.c +++ b/lustre/utils/liblustreapi_layout.c @@ -1797,7 +1797,7 @@ int llapi_layout_file_open(const char *path, int open_flags, mode_t mode, if (layout) { /* Make sure we are on a Lustre file system */ - if (comp->llc_pool_name[0] != '\0' && + if (comp != NULL && comp->llc_pool_name[0] != '\0' && !lov_pool_is_ignored(comp->llc_pool_name)) { rc = llapi_search_fsname(path, fsname); if (rc) { @@ -2452,7 +2452,7 @@ int llapi_layout_file_comp_add(const char *path, comp = __llapi_layout_cur_comp(layout); - if (comp->llc_pool_name[0] != '\0' && + if (comp != NULL && comp->llc_pool_name[0] != '\0' && !lov_pool_is_ignored(comp->llc_pool_name)) { rc = llapi_search_fsname(path, fsname); if (rc) { -- 1.8.3.1