From 664e947726ad3e64b59b2e3d43cd4ea01f7e5d5a Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 26 Jun 2017 23:57:12 +0200 Subject: [PATCH] coverity: add some error path for failed allocs Coverity reports some unchecked allocations. --- daemons/dmfilemapd/dmfilemapd.c | 3 ++- tools/lvmcmdline.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/daemons/dmfilemapd/dmfilemapd.c b/daemons/dmfilemapd/dmfilemapd.c index 43ae9705c..a1293dc24 100644 --- a/daemons/dmfilemapd/dmfilemapd.c +++ b/daemons/dmfilemapd/dmfilemapd.c @@ -709,7 +709,8 @@ static int _dmfilemapd(struct filemap_monitor *fm) * The correct program_id is retrieved from the group leader * following the call to dm_stats_list(). */ - dms = dm_stats_create(NULL); + if (!(dms = dm_stats_create(NULL))) + goto_bad; if (!dm_stats_bind_from_fd(dms, fm->fd)) { log_error("Could not bind dm_stats handle to file descriptor " diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index 0aca37a00..964e2950a 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -2703,7 +2703,10 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv) /* each command should start out with sigint flag cleared */ sigint_clear(); - cmd->name = dm_pool_strdup(cmd->mem, dm_basename(argv[0])); + if (!(cmd->name = dm_pool_strdup(cmd->mem, dm_basename(argv[0])))) { + log_error("Failed to strdup command basename."); + return ECMD_FAILED; + } configure_command_option_values(cmd->name);