diff --git a/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c b/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c index 3d3a6de02..4ec348f5a 100644 --- a/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c +++ b/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c @@ -184,16 +184,12 @@ int register_device(const char *device, goto_bad; if (!dmeventd_lvm2_command(state->mem, state->cmd_lvscan, sizeof(state->cmd_lvscan), - "lvscan --cache", device)) { - dmeventd_lvm2_exit_with_pool(state); + "lvscan --cache", device)) goto_bad; - } if (!dmeventd_lvm2_command(state->mem, state->cmd_lvconvert, sizeof(state->cmd_lvconvert), - "lvconvert --repair --use-policies", device)) { - dmeventd_lvm2_exit_with_pool(state); + "lvconvert --repair --use-policies", device)) goto_bad; - } *user = state; @@ -203,6 +199,9 @@ int register_device(const char *device, bad: log_error("Failed to monitor mirror %s.", device); + if (state) + dmeventd_lvm2_exit_with_pool(state); + return 0; } diff --git a/daemons/dmeventd/plugins/raid/dmeventd_raid.c b/daemons/dmeventd/plugins/raid/dmeventd_raid.c index 911ae7ad5..ae3fc862b 100644 --- a/daemons/dmeventd/plugins/raid/dmeventd_raid.c +++ b/daemons/dmeventd/plugins/raid/dmeventd_raid.c @@ -140,10 +140,8 @@ int register_device(const char *device, "lvscan --cache", device) || !dmeventd_lvm2_command(state->mem, state->cmd_lvconvert, sizeof(state->cmd_lvconvert), "lvconvert --config devices{ignore_suspended_devices=1} " - "--repair --use-policies", device)) { - dmeventd_lvm2_exit_with_pool(state); + "--repair --use-policies", device)) goto_bad; - } *user = state; @@ -153,6 +151,9 @@ int register_device(const char *device, bad: log_error("Failed to monitor RAID %s.", device); + if (state) + dmeventd_lvm2_exit_with_pool(state); + return 0; } diff --git a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c index a70d07cfe..bab7f0e37 100644 --- a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c +++ b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c @@ -254,10 +254,8 @@ int register_device(const char *device, if (!dmeventd_lvm2_command(state->mem, state->cmd_lvextend, sizeof(state->cmd_lvextend), - "lvextend --use-policies", device)) { - dmeventd_lvm2_exit_with_pool(state); + "lvextend --use-policies", device)) goto_bad; - } state->percent_check = CHECK_MINIMUM; *user = state; @@ -268,6 +266,9 @@ int register_device(const char *device, bad: log_error("Failed to monitor snapshot %s.", device); + if (state) + dmeventd_lvm2_exit_with_pool(state); + return 0; } diff --git a/daemons/dmeventd/plugins/thin/dmeventd_thin.c b/daemons/dmeventd/plugins/thin/dmeventd_thin.c index e447ba285..e7d24c580 100644 --- a/daemons/dmeventd/plugins/thin/dmeventd_thin.c +++ b/daemons/dmeventd/plugins/thin/dmeventd_thin.c @@ -359,10 +359,8 @@ int register_device(const char *device, goto_bad; if (!dmeventd_lvm2_command(state->mem, cmd_str, sizeof(cmd_str), - "_dmeventd_thin_command", device)) { - dmeventd_lvm2_exit_with_pool(state); + "_dmeventd_thin_command", device)) goto_bad; - } if (strncmp(cmd_str, "lvm ", 4) == 0) { if (!(state->cmd_str = dm_pool_strdup(state->mem, cmd_str + 4))) { @@ -401,6 +399,9 @@ inval: bad: log_error("Failed to monitor thin pool %s.", device); + if (state) + dmeventd_lvm2_exit_with_pool(state); + return 0; }