Whamcloud - gitweb
LU-17817 llapi: avoid potential NULL component 28/55028/4
authorRajeev Mishra <rajeevm@hpe.com>
Mon, 6 May 2024 20:12:54 +0000 (20:12 +0000)
committerOleg Drokin <green@whamcloud.com>
Wed, 29 May 2024 04:48:28 +0000 (04:48 +0000)
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 <rajeevm@hpe.com>
Change-Id: Id773fdbf031a2d11256140590f570f90da46ec3a
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55028
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/utils/liblustreapi_layout.c

index 310d283..bd2a055 100644 (file)
@@ -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) {