1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Ensure allocated device does not leak on error path

For unimplementd canonicalize_file_name set to NULL
This commit is contained in:
Zdenek Kabelac 2012-02-13 12:06:39 +00:00
parent 73e62cdc11
commit e66b3e8e3b
2 changed files with 6 additions and 1 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.71 - 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 missing reply_uuid in dm_event_get_registered_device().
Check for allocation failure in dmeventd restart(). Check for allocation failure in dmeventd restart().
Add few missing allocation failures tests in dmsetup. Add few missing allocation failures tests in dmsetup.

View File

@ -3043,6 +3043,8 @@ static char *_get_abspath(const char *path)
_path = canonicalize_file_name(path); _path = canonicalize_file_name(path);
#else #else
/* FIXME Provide alternative */ /* FIXME Provide alternative */
log_error(INTERNAL_ERROR "Unimplemented _get_abspath.");
_path = NULL;
#endif #endif
return _path; 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) static char *parse_loop_device_name(const char *dev, const char *dev_dir)
{ {
char *buf; char *buf;
char *device; char *device = NULL;
if (!(buf = dm_malloc(PATH_MAX))) if (!(buf = dm_malloc(PATH_MAX)))
return NULL; return NULL;
@ -3083,7 +3085,9 @@ static char *parse_loop_device_name(const char *dev, const char *dev_dir)
return buf; return buf;
error: error:
dm_free(device);
dm_free(buf); dm_free(buf);
return NULL; return NULL;
} }