1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

coverity: extra check for find_pool_seg

find_pool_seg may return NULL in some internal error stats.
Handle it explicitely.
This commit is contained in:
Zdenek Kabelac 2017-06-27 10:16:13 +02:00
parent b939ddf80c
commit e9c60f874e
2 changed files with 13 additions and 7 deletions

View File

@ -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 * However in case command would have crashed, such LV is
* left unmonitored and may potentially require dmeventd. * left unmonitored and may potentially require dmeventd.
*/ */
if ((lv_is_cache_pool_data(lv) || lv_is_cache_pool_metadata(lv)) && 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))) { if (!(seg = find_pool_seg(first_seg(lv))))
log_debug_activation("Skipping %smonitor of %s.%s", return_0;
(monitor) ? "" : "un", display_lvname(lv), if (!lv_is_used_cache_pool(seg->lv)) {
(monitor) ? " Cache pool activation for clearing only." : ""); log_debug_activation("Skipping %smonitor of %s.%s",
return 1; (monitor) ? "" : "un", display_lvname(lv),
(monitor) ? " Cache pool activation for clearing only." : "");
return 1;
}
} }
/* /*

View File

@ -5288,6 +5288,8 @@ static int _lvresize_adjust_extents(struct logical_volume *lv,
static int _lvresize_check_type(const struct logical_volume *lv, static int _lvresize_check_type(const struct logical_volume *lv,
const struct lvresize_params *lp) const struct lvresize_params *lp)
{ {
struct lv_segment *seg;
if (lv_is_origin(lv)) { if (lv_is_origin(lv)) {
if (lp->resize == LV_REDUCE) { if (lp->resize == LV_REDUCE) {
log_error("Snapshot origin volumes cannot be reduced in size yet."); 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) { } else if (lp->resize == LV_EXTEND) {
if (lv_is_thin_pool_metadata(lv) && 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.", log_error("Support for online metadata resize of %s not detected.",
display_lvname(lv)); display_lvname(lv));
return 0; return 0;