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

clang: ensure pointer is defined

Check for new_segtype and lv is defined
before dereferencing.
This commit is contained in:
Zdenek Kabelac 2024-10-25 00:07:16 +02:00
parent ea4daeb28e
commit 5ec8f744d0
2 changed files with 10 additions and 1 deletions

View File

@ -1834,6 +1834,11 @@ int historical_glv_remove(struct generic_logical_volume *glv)
*/
int lv_remove(struct logical_volume *lv)
{
if (!lv) {
log_error(INTERNAL_ERROR "Cannot remove undefined LV.");
return 0;
}
if (lv_is_historical(lv))
return historical_glv_remove(lv->this_glv);

View File

@ -6105,9 +6105,13 @@ static int _log_prohibited_option(const struct lv_segment *seg_from,
if (seg_from->segtype == new_segtype)
log_error("%s not allowed when converting %s LV %s.",
opt_str, lvseg_name(seg_from), display_lvname(seg_from->lv));
else
else if (new_segtype)
log_error("%s not allowed for LV %s when converting from %s to %s.",
opt_str, display_lvname(seg_from->lv), lvseg_name(seg_from), new_segtype->name);
else {
log_error(INTERNAL_ERROR "New segtype is not defined.");
return 0;
}
return 1;
}