[PATCH 01/13] fix: memory leak in mdmon_pid()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Hawrylewicz Czarnowski, Przemyslaw
Date: Thursday, April 22, 2010 - 3:10 pm

devnum2devname() returns pointer to memory allocated with strdup.
It must be released to prevent memory leak.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
---
 util.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/util.c b/util.c
index d292a66..423b66f 100644
--- a/util.c
+++ b/util.c
@@ -1502,7 +1502,11 @@ int mdmon_pid(int devnum)
 	char pid[10];
 	int fd;
 	int n;
-	sprintf(path, "%s/%s.pid", pid_dir, devnum2devname(devnum));
+	char *devname = devnum2devname(devnum);
+
+	sprintf(path, "%s/%s.pid", pid_dir, devname);
+	free(devname);
+
 	fd = open(path, O_RDONLY | O_NOATIME, 0);
 
 	if (fd < 0)
-- 
1.6.4.2

--
Best Regards,
Przemyslaw Hawrylewicz-Czarnowski
Software Development Engineer


--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 01/13] fix: memory leak in mdmon_pid(), Hawrylewicz Czarnows ..., (Thu Apr 22, 3:10 pm)