Blame SOURCES/0015-kpartx-Don-t-leak-memory-when-getblock-returns-NULL.patch
|
|
68b27c |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
68b27c |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
68b27c |
Date: Tue, 11 May 2021 16:03:13 -0500
|
|
|
68b27c |
Subject: [PATCH] kpartx: Don't leak memory when getblock returns NULL
|
|
|
68b27c |
|
|
|
68b27c |
If a new block was allocated, but couldn't be filled, getblock will
|
|
|
68b27c |
discard it. When it does so, it needs to free the block to avoid leaking
|
|
|
68b27c |
memory. Found by coverity.
|
|
|
68b27c |
|
|
|
68b27c |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
68b27c |
---
|
|
|
68b27c |
kpartx/kpartx.c | 2 ++
|
|
|
68b27c |
1 file changed, 2 insertions(+)
|
|
|
68b27c |
|
|
|
68b27c |
diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
|
|
|
68b27c |
index 8ff116b8..7bc64543 100644
|
|
|
68b27c |
--- a/kpartx/kpartx.c
|
|
|
68b27c |
+++ b/kpartx/kpartx.c
|
|
|
68b27c |
@@ -766,6 +766,8 @@ getblock (int fd, unsigned int blknr) {
|
|
|
68b27c |
if (read(fd, bp->block, secsz) != secsz) {
|
|
|
68b27c |
fprintf(stderr, "read error, sector %d\n", secnr);
|
|
|
68b27c |
blockhead = bp->next;
|
|
|
68b27c |
+ free(bp->block);
|
|
|
68b27c |
+ free(bp);
|
|
|
68b27c |
return NULL;
|
|
|
68b27c |
}
|
|
|
68b27c |
|