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

Clean up group struct in _stats_create_group() error path

Fix a double free in the error path from _stats_create_group() by
clearing the group struct embedded in the dm_stats handle before
returning:

    device-mapper: message ioctl on  (253:0) failed: Invalid argument
    Could not create regions from file /var/tmp/File With Spaces.
    free(): double free detected in tcache 2
    Aborted (core dumped)
This commit is contained in:
Bryn M. Reeves 2023-08-31 16:59:02 +01:00 committed by Zdeněk Kabeláč
parent 25ef7a7b1a
commit eda99fc383

View File

@ -3908,9 +3908,14 @@ static int _stats_create_group(struct dm_stats *dms, dm_bitset_t regions,
/* force an update of the group tag stored in aux_data */ /* force an update of the group tag stored in aux_data */
if (!_stats_set_aux(dms, *group_id, dms->regions[*group_id].aux_data)) if (!_stats_set_aux(dms, *group_id, dms->regions[*group_id].aux_data))
return 0; goto bad;
return 1; return 1;
bad:
group->group_id = DM_STATS_GROUP_NOT_PRESENT;
group->regions = NULL;
dm_free((char *) group->alias);
return 0;
} }
static int _stats_group_check_overlap(const struct dm_stats *dms, static int _stats_group_check_overlap(const struct dm_stats *dms,