[PATCH 2/5] libmount: fix memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Found with scan-build.

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 libmount/src/utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index 0fcc1d0..8b80609 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -1107,7 +1107,7 @@ char *mnt_get_kernel_cmdline_option(const char *name)
 int mnt_guess_system_root(dev_t devno, struct libmnt_cache *cache, char **path)
 {
 	char buf[PATH_MAX];
-	char *dev = NULL, *spec;
+	char *dev = NULL, *spec = NULL;
 	unsigned int x, y;
 	int allocated = 0;
 
@@ -1169,8 +1169,8 @@ int mnt_guess_system_root(dev_t devno, struct libmnt_cache *cache, char **path)
 		if (dev && !cache)
 			allocated = 1;
 	}
-	free(spec);
 done:
+	free(spec);
 	if (dev) {
 		*path = allocated ? dev : strdup(dev);
 		if (!path)
-- 
2.8.0

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux