summaryrefslogtreecommitdiff
path: root/lib/locking
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2022-02-22 15:03:11 -0600
committerDavid Teigland <teigland@redhat.com>2022-02-24 17:22:04 -0600
commit4eb04c8c05e52776891f62863375ceacf866de77 (patch)
tree46016e2027141fa85b7e5aae58c1ce6c14bb41b3 /lib/locking
parent00c3069872ab488f66f14c8c2727bd080affc05e (diff)
downloadlvm2-4eb04c8c05e52776891f62863375ceacf866de77.tar.gz
devices: fix dev_name assumptions
dev_name(dev) returns "[unknown]" if there are no names on dev->aliases. It's meant mainly for log messages. Many places assume a valid path name is returned, and use it directly. A caller that wants to use the path from dev_name() must first check if the dev has any paths with dm_list_empty(&dev->aliases).
Diffstat (limited to 'lib/locking')
-rw-r--r--lib/locking/lvmlockd.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index b598df3d6..60c80f1b1 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -272,6 +272,8 @@ static void _lockd_retrive_vg_pv_list(struct volume_group *vg,
i = 0;
dm_list_iterate_items(pvl, &vg->pvs) {
+ if (!pvl->pv->dev || dm_list_empty(&pvl->pv->dev->aliases))
+ continue;
lock_pvs->path[i] = strdup(pv_dev_name(pvl->pv));
if (!lock_pvs->path[i]) {
log_error("Fail to allocate PV path for VG %s", vg->name);
@@ -341,6 +343,8 @@ static void _lockd_retrive_lv_pv_list(struct volume_group *vg,
dm_list_iterate_items(pvl, &vg->pvs) {
if (lv_is_on_pv(lv, pvl->pv)) {
+ if (!pvl->pv->dev || dm_list_empty(&pvl->pv->dev->aliases))
+ continue;
lock_pvs->path[i] = strdup(pv_dev_name(pvl->pv));
if (!lock_pvs->path[i]) {
log_error("Fail to allocate PV path for LV %s/%s",