[dm-devel] [PATCH] libmultipath: fix memory API logic error

Bart Van Assche Bart.VanAssche at sandisk.com
Mon Aug 15 13:46:32 UTC 2016


On 08/15/16 03:59, tang.junhui at zte.com.cn wrote:
> From: "tang.junhui" <tang.junhui at zte.com.cn>
>
> Memroy API use mem_allocated to record the total size of used memory,
> however, it's wrong to use size(p) as the length of freed memory in xfree(),
> and memory may also be allocated by STRDUP() or REALLOC(), which is
> not calculated into mem_allocated, so the total size of used memory is
> not correctly. For these reasons, we removed these incorrectly code to keep
> the code clean.

Nice work. BTW, I think it's worth mentioning that this patch also fixes 
a data race. Without this patch the global variable mem_allocated is 
manipulated by multiple threads without using atomics and without 
serializing concurrent accesses.

Bart.





More information about the dm-devel mailing list