On Wed, Dec 12, 2012 at 02:30:59PM +0100, Lukas Czerner wrote:
> Currently we could access unallocated memory in fiemap because we're
> using uninitialized variable 'fiemap' in fiemap_f(). In fact this has
> been spotted on x390s machine where xfs_io would segfault.
> The problem happens in the for cycle which seems to be intended to
> compute the header item spacing. However at that point the fiemap
> structure has just been allocated and does not contain any extents
> yet, so it is entirely useless and it never actually worked.
> This patch removes this dead code mentioned above which also fixes
> the possible unallocated memory access.
I think the correct fix is to move the formatting calculation to
after the first fiemap call. The formatting is actually useful
because it calculates column widths that make sure output is fairly
nicely aligned, and that is definitely of value when you are looking
at output thousands of extents long...