[PATCH] Potential memory leak in pktloc.c
Rahul Jain
rahul.jain at samsung.com
Wed Dec 16 21:03:05 PST 2015
From: Amit Khatri <amit.khatri at samsung.com>
In scneario, where file modification time is unchanged, code is returning 0
form read_pktlocs(). It causes memory leak for path variable.
Memory for this variable is allocated inside build_sysconf_path()
by asprintf() function.
Signed-off-by: Amit Khatri <amit.khatri at samsung.com>
Signed-off-by: Rahul Jain <rahul.jain at samsung.com>
---
lib/route/pktloc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/route/pktloc.c b/lib/route/pktloc.c
index 27d63be..75d049e 100644
--- a/lib/route/pktloc.c
+++ b/lib/route/pktloc.c
@@ -101,8 +101,10 @@ static int read_pktlocs(void)
/* if stat fails, just try to read the file */
if (stat(path, &st) == 0) {
/* Don't re-read file if file is unchanged */
- if (last_read == st.st_mtime)
- return 0;
+ if (last_read == st.st_mtime) {
+ err = 0;
+ goto errout;
+ }
}
NL_DBG(2, "Reading packet location file \"%s\"\n", path);
--
1.9.1
More information about the libnl
mailing list