From 6c67f05ca7f5f0ab6c5988ab30d4fdeff08b9c25 Mon Sep 17 00:00:00 2001 From: Volkan Unal Date: Wed, 24 Jun 2026 11:02:09 +0100 Subject: [PATCH] dasdinfo: Fix memory leak in dinfo_get_uid_from_devnode() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function dinfo_get_uid_from_devnode() allocates memory for readbuf but fails to free it in two code paths: 1. When the device name is truncated (error path) 2. At the successful function exit Add the missing free(readbuf) calls to prevent memory leaks in both paths. Reviewed-by: Jan Höppner Signed-off-by: Volkan Unal Signed-off-by: Jan Höppner --- dasdinfo/dasdinfo.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dasdinfo/dasdinfo.c b/dasdinfo/dasdinfo.c index d69e454b..d471f623 100644 --- a/dasdinfo/dasdinfo.c +++ b/dasdinfo/dasdinfo.c @@ -495,6 +495,7 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode) fprintf(stderr, "Error: Device name was truncated\n"); free(path); + free(readbuf); return -1; } @@ -504,6 +505,7 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode) closedir(directory); free(path); + free(readbuf); return 0; }