summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2015-07-09 12:07:34 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2015-07-09 12:07:41 +0200
commit023cf21848bdf75bade560f6f43b2dea62a54f80 (patch)
tree927646cec7c98148f0f44b25ceb239943a404fd0
parentcb305b9fc0ae3f554b71aa3839d091424c660e63 (diff)
downloadlvm2-023cf21848bdf75bade560f6f43b2dea62a54f80.tar.gz
coverity: fix possible invalid dereferences
lib/format1/import-export.c:167: var_deref_op: Dereferencing null pointer "vg->lvm1_system_id" lib/cache/lvmetad.c:1023: var_deref_op: Dereferencing null pointer "this" daemons/lvmlockd/lvmlockd-core.c:2659: check_after_deref: Null-checking "act" suggests that it may be null, but it has already been dereferenced on all paths leading to the check /daemons/lvmetad/lvmetad-core.c:1024: check_after_deref: Null-checking "pvmeta" suggests that it may be null, but it has already been dereferenced on all paths leading to the check
-rw-r--r--daemons/lvmetad/lvmetad-core.c6
-rw-r--r--daemons/lvmlockd/lvmlockd-core.c3
-rw-r--r--lib/cache/lvmetad.c3
-rw-r--r--lib/format1/import-export.c2
4 files changed, 6 insertions, 8 deletions
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index f4e77b7e8..b4382c758 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -999,7 +999,8 @@ static response pv_gone(lvmetad_state *s, request r)
DEBUGLOG(s, "pv_gone (updated): %s / %" PRIu64, pvid, device);
- pvmeta = dm_hash_lookup(s->pvid_to_pvmeta, pvid);
+ if (!(pvmeta = dm_hash_lookup(s->pvid_to_pvmeta, pvid)))
+ return reply_unknown("PVID does not exist");
vgid = dm_hash_lookup(s->pvid_to_vgid, pvid);
dm_hash_remove_binary(s->device_to_pvid, &device, sizeof(device));
@@ -1021,9 +1022,6 @@ static response pv_gone(lvmetad_state *s, request r)
dm_free(vgid);
}
- if (!pvmeta)
- return reply_unknown("PVID does not exist");
-
if (!alt_device)
dm_config_destroy(pvmeta);
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 1b7f49464..ff5510c0e 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -2661,8 +2661,7 @@ static int rem_lockspace(struct action *act)
}
ls->thread_work = 1;
ls->thread_stop = 1;
- if (act)
- list_add_tail(&act->list, &ls->actions);
+ list_add_tail(&act->list, &ls->actions);
pthread_cond_signal(&ls->cond);
pthread_mutex_unlock(&ls->mutex);
pthread_mutex_unlock(&lockspaces_mutex);
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 783a114d7..89056406e 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -1017,7 +1017,8 @@ static int _lvmetad_pvscan_single(struct metadata_area *mda, void *baton)
struct _lvmetad_pvscan_baton *b = baton;
struct volume_group *this;
- this = mda_is_ignored(mda) ? NULL : mda->ops->vg_read(b->fid, "", mda, NULL, NULL, 1);
+ if (!(this = mda_is_ignored(mda) ? NULL : mda->ops->vg_read(b->fid, "", mda, NULL, NULL, 1)))
+ return 1;
/* FIXME Also ensure contents match etc. */
if (!b->vg || this->seqno > b->vg->seqno)
diff --git a/lib/format1/import-export.c b/lib/format1/import-export.c
index 72f69462a..275583d18 100644
--- a/lib/format1/import-export.c
+++ b/lib/format1/import-export.c
@@ -164,7 +164,7 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem __attribute__((unused
/* Is VG already exported or being exported? */
if (vg && vg_is_exported(vg)) {
/* Does system_id need setting? */
- if (!*vg->lvm1_system_id ||
+ if ((vg->lvm1_system_id && !*vg->lvm1_system_id) ||
strncmp(vg->lvm1_system_id, EXPORTED_TAG,
sizeof(EXPORTED_TAG) - 1)) {
if (!generate_lvm1_system_id(cmd, (char *)pvd->system_id, EXPORTED_TAG))