From 35d68b2101f559cb293dca38774eef07639e2017 Mon Sep 17 00:00:00 2001 From: Jan Polensky Date: Thu, 11 Sep 2025 18:43:55 +0200 Subject: [PATCH] dasdinfo: Fix memory leak by freeing readbuf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Jan Höppner Signed-off-by: Jan Polensky Signed-off-by: Jan Höppner --- dasdinfo/dasdinfo.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dasdinfo/dasdinfo.c b/dasdinfo/dasdinfo.c index cc84dce0..cb9a36e6 100644 --- a/dasdinfo/dasdinfo.c +++ b/dasdinfo/dasdinfo.c @@ -364,12 +364,16 @@ static int dinfo_get_dev_from_blockdev(char *blockdev, dev_t *dev) path = util_path_sysfs("block/%s/dev", blockdev); if (util_file_read_line(readbuf, RD_BUFFER_SIZE, path) < 0) { free(path); + free(readbuf); return -1; } free(path); - if (dinfo_extract_dev(dev, readbuf) != 0) + if (dinfo_extract_dev(dev, readbuf) != 0) { + free(readbuf); return -1; + } + free(readbuf); return 0; }