]> sourceware.org Git - lvm2.git/commitdiff
Ensure allocated device does not leak on error path
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 13 Feb 2012 12:06:39 +0000 (12:06 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 13 Feb 2012 12:06:39 +0000 (12:06 +0000)
For unimplementd canonicalize_file_name set to NULL

WHATS_NEW_DM
tools/dmsetup.c

index 43cc9e3886f43ddc4d5b15cf2d35c59335626dcf..4da95deed4426564422a53a131e2e94bc6108133 100644 (file)
@@ -1,5 +1,6 @@
 Version 1.02.71 - 
 ====================================
+  Fix memory leak in fail path of parse_loop_device_name() in dmsetup.
   Check for missing reply_uuid in dm_event_get_registered_device().
   Check for allocation failure in dmeventd restart().
   Add few missing allocation failures tests in dmsetup.
index 11c7bcd7eb1b8ef28782761287280f470ae5cef6..f59d39d23cf9e8e3c7fc3d6fcd7092ddf5c49343 100644 (file)
@@ -3043,6 +3043,8 @@ static char *_get_abspath(const char *path)
        _path = canonicalize_file_name(path);
 #else
        /* FIXME Provide alternative */
+       log_error(INTERNAL_ERROR "Unimplemented _get_abspath.");
+       _path = NULL;
 #endif
        return _path;
 }
@@ -3050,7 +3052,7 @@ static char *_get_abspath(const char *path)
 static char *parse_loop_device_name(const char *dev, const char *dev_dir)
 {
        char *buf;
-       char *device;
+       char *device = NULL;
 
        if (!(buf = dm_malloc(PATH_MAX)))
                return NULL;
@@ -3083,7 +3085,9 @@ static char *parse_loop_device_name(const char *dev, const char *dev_dir)
        return buf;
 
 error:
+       dm_free(device);
        dm_free(buf);
+
        return NULL;
 }
 
This page took 0.04398 seconds and 5 git commands to generate.