mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
dasdinfo: Fix memory leak in dinfo_get_uid_from_devnode()
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 <hoeppner@linux.ibm.com> Signed-off-by: Volkan Unal <vunal@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user