If a new block was allocated, but couldn't be filled, getblock will discard it. When it does so, it needs to free the block to avoid leaking memory. Found by coverity. Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx> --- kpartx/kpartx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c index 8ff116b8..7bc64543 100644 --- a/kpartx/kpartx.c +++ b/kpartx/kpartx.c @@ -766,6 +766,8 @@ getblock (int fd, unsigned int blknr) { if (read(fd, bp->block, secsz) != secsz) { fprintf(stderr, "read error, sector %d\n", secnr); blockhead = bp->next; + free(bp->block); + free(bp); return NULL; } -- 2.17.2 -- dm-devel mailing list dm-devel@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/dm-devel