Whamcloud - gitweb
LU-9513 liblustre: always check return value 54/27154/3
authorNiu Yawei <yawei.niu@intel.com>
Wed, 17 May 2017 08:07:07 +0000 (04:07 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 29 May 2017 18:01:38 +0000 (18:01 +0000)
Always check if the return value of __llapi_layout_cur_comp() is
NULL.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: Ibc803de5f27b981b0daa5e7be1a18adde9a46a18
Reviewed-on: https://review.whamcloud.com/27154
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/liblustreapi_layout.c

index 557765d..dbf1369 100644 (file)
@@ -1962,6 +1962,11 @@ int llapi_layout_file_comp_del(const char *path, uint32_t id, uint32_t flags)
 
        llapi_layout_comp_extent_set(layout, 0, LUSTRE_EOF);
        comp = __llapi_layout_cur_comp(layout);
 
        llapi_layout_comp_extent_set(layout, 0, LUSTRE_EOF);
        comp = __llapi_layout_cur_comp(layout);
+       if (comp == NULL) {
+               llapi_layout_free(layout);
+               return -1;
+       }
+
        comp->llc_id = id;
        comp->llc_flags = flags;
 
        comp->llc_id = id;
        comp->llc_flags = flags;