1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

segtype: replace mempool allocation

So this is a bit more complex and possibly worth futher checking.

ATM  clvmd drops  cmd->mem  mempool AFTER refresh of cmd.
So anything allocating from cmd->mem during toolcontext init
will likely die at some point in time.

As a quick fix - just use regular malloc/free for 'dso' alloction.

It's worth to note -  cmd->libmem seems to be often misused
causing hidden memleaking for clvmd.
This commit is contained in:
Zdenek Kabelac 2018-02-13 19:00:47 +01:00
parent e40768ac32
commit 32febed8d5
5 changed files with 10 additions and 3 deletions

View File

@ -1692,7 +1692,7 @@ char *get_monitor_dso_path(struct cmd_context *cmd, int id)
get_shared_library_path(cmd, libpath, path, sizeof(path)); get_shared_library_path(cmd, libpath, path, sizeof(path));
return dm_pool_strdup(cmd->mem, path); return dm_strdup(path);
} }
static char *_build_target_uuid(struct cmd_context *cmd, const struct logical_volume *lv) static char *_build_target_uuid(struct cmd_context *cmd, const struct logical_volume *lv)

View File

@ -531,6 +531,7 @@ static int _mirrored_modules_needed(struct dm_pool *mem,
static void _mirrored_destroy(struct segment_type *segtype) static void _mirrored_destroy(struct segment_type *segtype)
{ {
dm_free(segtype->dso);
dm_free(segtype); dm_free(segtype);
} }

View File

@ -363,6 +363,7 @@ static int _raid_target_status_compatible(const char *type)
static void _raid_destroy(struct segment_type *segtype) static void _raid_destroy(struct segment_type *segtype)
{ {
dm_free(segtype->dso);
dm_free((void *) segtype); dm_free((void *) segtype);
} }
@ -629,7 +630,8 @@ static struct segment_type *_init_raid_segtype(struct cmd_context *cmd,
segtype->flags = SEG_RAID | SEG_ONLY_EXCLUSIVE | rt->extra_flags; segtype->flags = SEG_RAID | SEG_ONLY_EXCLUSIVE | rt->extra_flags;
/* Never monitor raid0 or raid0_meta LVs */ /* Never monitor raid0 or raid0_meta LVs */
if (!segtype_is_any_raid0(segtype)) { if (!segtype_is_any_raid0(segtype) &&
dso && (dso = dm_strdup(dso))) {
segtype->dso = dso; segtype->dso = dso;
segtype->flags |= monitored; segtype->flags |= monitored;
} }
@ -650,7 +652,7 @@ int init_multiple_segtypes(struct cmd_context *cmd, struct segtype_library *segl
#endif #endif
{ {
struct segment_type *segtype; struct segment_type *segtype;
const char *dso; const char *dso = NULL;
unsigned i; unsigned i;
uint64_t monitored = 0; uint64_t monitored = 0;
@ -669,5 +671,7 @@ int init_multiple_segtypes(struct cmd_context *cmd, struct segtype_library *segl
/* segtype is already destroyed */ /* segtype is already destroyed */
return_0; return_0;
dm_free(dso);
return 1; return 1;
} }

View File

@ -224,6 +224,7 @@ static int _snap_modules_needed(struct dm_pool *mem,
static void _snap_destroy(struct segment_type *segtype) static void _snap_destroy(struct segment_type *segtype)
{ {
dm_free(segtype->dso);
dm_free(segtype); dm_free(segtype);
} }

View File

@ -745,6 +745,7 @@ static int _thin_target_present(struct cmd_context *cmd,
static void _thin_destroy(struct segment_type *segtype) static void _thin_destroy(struct segment_type *segtype)
{ {
dm_free(segtype->dso);
dm_free(segtype); dm_free(segtype);
} }