mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
covscan: free wwid strings in lvmcache
This commit is contained in:
parent
e97cf8552c
commit
c21783d492
46
lib/cache/lvmcache.c
vendored
46
lib/cache/lvmcache.c
vendored
@ -644,8 +644,10 @@ static int _all_multipath_components(struct cmd_context *cmd, struct lvmcache_in
|
|||||||
struct device *dev_mp = NULL;
|
struct device *dev_mp = NULL;
|
||||||
struct device *dev1 = NULL;
|
struct device *dev1 = NULL;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
char wwid1_buf[DEV_WWID_SIZE] = { 0 };
|
||||||
|
char wwid_buf[DEV_WWID_SIZE] = { 0 };
|
||||||
const char *wwid1 = NULL;
|
const char *wwid1 = NULL;
|
||||||
const char *wwid;
|
const char *wwid = NULL;
|
||||||
int diff_wwid = 0;
|
int diff_wwid = 0;
|
||||||
int same_wwid = 0;
|
int same_wwid = 0;
|
||||||
int dev_is_mp;
|
int dev_is_mp;
|
||||||
@ -667,14 +669,23 @@ static int _all_multipath_components(struct cmd_context *cmd, struct lvmcache_in
|
|||||||
dev = info->dev;
|
dev = info->dev;
|
||||||
dev_is_mp = (cmd->dev_types->device_mapper_major == MAJOR(dev->dev)) && dev_has_mpath_uuid(cmd, dev, NULL);
|
dev_is_mp = (cmd->dev_types->device_mapper_major == MAJOR(dev->dev)) && dev_has_mpath_uuid(cmd, dev, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* dev_mpath_component_wwid allocates wwid from dm_pool,
|
||||||
|
* device_id_system_read does not and needs free.
|
||||||
|
*/
|
||||||
|
|
||||||
if (dev_is_mp) {
|
if (dev_is_mp) {
|
||||||
if ((wwid1 = dev_mpath_component_wwid(cmd, dev))) {
|
if ((wwid1 = dev_mpath_component_wwid(cmd, dev))) {
|
||||||
|
strncpy(wwid1_buf, wwid1, DEV_WWID_SIZE);
|
||||||
dev_mp = dev;
|
dev_mp = dev;
|
||||||
dev1 = dev;
|
dev1 = dev;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((wwid1 = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_WWID)))
|
if ((wwid1 = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_WWID))) {
|
||||||
|
strncpy(wwid1_buf, wwid1, DEV_WWID_SIZE);
|
||||||
|
free((char *)wwid1);
|
||||||
dev1 = dev;
|
dev1 = dev;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -682,31 +693,36 @@ static int _all_multipath_components(struct cmd_context *cmd, struct lvmcache_in
|
|||||||
dev = devl->dev;
|
dev = devl->dev;
|
||||||
dev_is_mp = (cmd->dev_types->device_mapper_major == MAJOR(dev->dev)) && dev_has_mpath_uuid(cmd, dev, NULL);
|
dev_is_mp = (cmd->dev_types->device_mapper_major == MAJOR(dev->dev)) && dev_has_mpath_uuid(cmd, dev, NULL);
|
||||||
|
|
||||||
if (dev_is_mp)
|
if (dev_is_mp) {
|
||||||
wwid = dev_mpath_component_wwid(cmd, dev);
|
if ((wwid = dev_mpath_component_wwid(cmd, dev)))
|
||||||
else
|
strncpy(wwid_buf, wwid, DEV_WWID_SIZE);
|
||||||
wwid = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_WWID);
|
} else {
|
||||||
|
if ((wwid = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_WWID))) {
|
||||||
|
strncpy(wwid_buf, wwid, DEV_WWID_SIZE);
|
||||||
|
free((char *)wwid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!wwid && wwid1) {
|
if (!wwid_buf[0] && wwid1_buf[0]) {
|
||||||
log_debug("Different wwids for duplicate PVs %s %s %s none",
|
log_debug("Different wwids for duplicate PVs %s %s %s none",
|
||||||
dev_name(dev1), wwid1, dev_name(dev));
|
dev_name(dev1), wwid1_buf, dev_name(dev));
|
||||||
diff_wwid++;
|
diff_wwid++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wwid)
|
if (!wwid_buf[0])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!wwid1) {
|
if (!wwid1_buf[0]) {
|
||||||
wwid1 = wwid;
|
memcpy(wwid1_buf, wwid_buf, DEV_WWID_SIZE);
|
||||||
dev1 = dev;
|
dev1 = dev;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Different wwids indicates these are not multipath components. */
|
/* Different wwids indicates these are not multipath components. */
|
||||||
if (strcmp(wwid1, wwid)) {
|
if (strcmp(wwid1_buf, wwid_buf)) {
|
||||||
log_debug("Different wwids for duplicate PVs %s %s %s %s",
|
log_debug("Different wwids for duplicate PVs %s %s %s %s",
|
||||||
dev_name(dev1), wwid1, dev_name(dev), wwid);
|
dev_name(dev1), wwid1_buf, dev_name(dev), wwid_buf);
|
||||||
diff_wwid++;
|
diff_wwid++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -714,7 +730,7 @@ static int _all_multipath_components(struct cmd_context *cmd, struct lvmcache_in
|
|||||||
/* Different mpath devs with the same wwid shouldn't happen. */
|
/* Different mpath devs with the same wwid shouldn't happen. */
|
||||||
if (dev_is_mp && dev_mp) {
|
if (dev_is_mp && dev_mp) {
|
||||||
log_print("Found multiple multipath devices for PVID %s WWID %s: %s %s",
|
log_print("Found multiple multipath devices for PVID %s WWID %s: %s %s",
|
||||||
pvid, wwid1, dev_name(dev_mp), dev_name(dev));
|
pvid, wwid1_buf, dev_name(dev_mp), dev_name(dev));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -730,7 +746,7 @@ static int _all_multipath_components(struct cmd_context *cmd, struct lvmcache_in
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (dev_mp)
|
if (dev_mp)
|
||||||
log_debug("Found multipath device %s for PVID %s WWID %s.", dev_name(dev_mp), pvid, wwid1);
|
log_debug("Found multipath device %s for PVID %s WWID %s.", dev_name(dev_mp), pvid, wwid1_buf);
|
||||||
|
|
||||||
*dev_mpath = dev_mp;
|
*dev_mpath = dev_mp;
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user