master - coverity: extra check for find_pool_seg
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e9c60f874ef02c8c5539310223e61e73a8103681 Commit: e9c60f874ef02c8c5539310223e61e73a8103681 Parent: b939ddf80c7370ae17e26c6d05482be6799245e3 Author: Zdenek Kabelac <[email protected]> AuthorDate: Tue Jun 27 10:16:13 2017 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Tue Jun 27 12:15:15 2017 +0200
coverity: extra check for find_pool_seg
find_pool_seg may return NULL in some internal error stats. Handle it explicitely.
--- lib/activate/activate.c | 15 +++++++++------ lib/metadata/lv_manip.c | 5 ++++- 2 files changed, 13 insertions(+), 7 deletions(-)
lib/activate/activate.c +9 -6
@@ -1849,12 +1849,15 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume* However in case command would have crashed, such LV is * left unmonitored and may potentially require dmeventd. */ -if ((lv_is_cache_pool_data (lv) ||lv_is_cache_pool_metadata (lv)) && - !lv_is_used_cache_pool ((find_pool_seg (first_seg (lv))->lv))) { -log_debug_activation ("Skipping %smonitor of %s.%s" , - (monitor) ?"" :"un" ,display_lvname (lv), - (monitor) ?" Cache pool activation for clearing only." :"" ); -return 1 ; +if (lv_is_cache_pool_data (lv) ||lv_is_cache_pool_metadata (lv)) { +if (!(seg =find_pool_seg (first_seg (lv)))) + return_0; +if (!lv_is_used_cache_pool (seg->lv)) { +log_debug_activation ("Skipping %smonitor of %s.%s" , + (monitor) ?"" :"un" ,display_lvname (lv), + (monitor) ?" Cache pool activation for clearing only." :"" ); +return 1 ; + } }/*
lib/metadata/lv_manip.c +4 -1
@@ -5288,6 +5288,8 @@ static int _lvresize_adjust_extents(struct logical_volume *lv,static int _lvresize_check_type (const struct logical_volume *lv,const struct lvresize_params *lp) { +struct lv_segment *seg; +if (lv_is_origin (lv)) {if (lp->resize ==LV_REDUCE ) {log_error ("Snapshot origin volumes cannot be reduced in size yet." );
@@ -5313,7 +5315,8 @@ static int _lvresize_check_type(const struct logical_volume *lv, } }else if (lp->resize ==LV_EXTEND ) {if (lv_is_thin_pool_metadata (lv) && - !thin_pool_feature_supported (find_pool_seg (first_seg (lv))->lv,THIN_FEATURE_METADATA_RESIZE )) { + (!(seg =find_pool_seg (first_seg (lv))) || + !thin_pool_feature_supported (seg->lv,THIN_FEATURE_METADATA_RESIZE ))) {log_error ("Support for online metadata resize of %s not detected." ,display_lvname (lv));return 0 ;