mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
libdm: fix stats walk compatibility with older dmsetup
The current dmsetup.c handles DR_STATS and DR_STATS_META reports separately in _display_info_cols(), meaning that the stats walk functions are never called for these report types. Versions before v2.02.159 have a loop using dm_stats_walk_do() and dm_stats_walk_while(), that executes once for non-stats reports, and once per region, or area, for DR_STATS/DR_STATS_META reports. This older behaviour relies on the documented behaviour that the walk functions will accept a NULL pointer as the struct dm_stats* argument. This was broken by commit f1f2df7b: the NULL test on dms and dms->regions were incorrectly moved from the dm_stats_walk_end() wrapper to the internal '_stats_walk_end()' helper. Since the pointer is dereferenced in between these points, using an older dmsetup with current libdm results in a segfault when running a non-stats report: # dmsetup info -c vg00/lvol0 Segmentation fault (core dumped) Restore the NULL checks to the wrapper function as intended.
This commit is contained in:
parent
0a480c5c52
commit
6ec8854fdb
@ -1,5 +1,6 @@
|
|||||||
Version 1.02.136 -
|
Version 1.02.136 -
|
||||||
======================================
|
======================================
|
||||||
|
Fix stats walk segfault with dmsetup older than v1.02.129
|
||||||
|
|
||||||
Version 1.02.135 - 26th September 2016
|
Version 1.02.135 - 26th September 2016
|
||||||
======================================
|
======================================
|
||||||
|
@ -1526,9 +1526,6 @@ static void _stats_walk_end_areas(const struct dm_stats *dms, uint64_t *flags,
|
|||||||
static int _stats_walk_end(const struct dm_stats *dms, uint64_t *flags,
|
static int _stats_walk_end(const struct dm_stats *dms, uint64_t *flags,
|
||||||
uint64_t *cur_r, uint64_t *cur_a, uint64_t *cur_g)
|
uint64_t *cur_r, uint64_t *cur_a, uint64_t *cur_g)
|
||||||
{
|
{
|
||||||
if (!dms || !dms->regions)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (*flags & DM_STATS_WALK_AREA) {
|
if (*flags & DM_STATS_WALK_AREA) {
|
||||||
_stats_walk_end_areas(dms, flags, cur_r, cur_a, cur_g);
|
_stats_walk_end_areas(dms, flags, cur_r, cur_a, cur_g);
|
||||||
goto out;
|
goto out;
|
||||||
@ -1553,6 +1550,9 @@ out:
|
|||||||
|
|
||||||
int dm_stats_walk_end(struct dm_stats *dms)
|
int dm_stats_walk_end(struct dm_stats *dms)
|
||||||
{
|
{
|
||||||
|
if (!dms || !dms->regions)
|
||||||
|
return 1;
|
||||||
|
|
||||||
if (_stats_walk_end(dms, &dms->cur_flags,
|
if (_stats_walk_end(dms, &dms->cur_flags,
|
||||||
&dms->cur_region, &dms->cur_area,
|
&dms->cur_region, &dms->cur_area,
|
||||||
&dms->cur_group)) {
|
&dms->cur_group)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user