main - device_id: fix segfault verifying serial for non-pv
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6613a61d3b5ce4d12a6fef79195eac34f30ef4da Commit: 6613a61d3b5ce4d12a6fef79195eac34f30ef4da Parent: a74468116ea51542e409e4bc393c63dc7ddb20b6 Author: David Teigland <[email protected]> AuthorDate: Fri Dec 2 11:59:09 2022 -0600 Committer: David Teigland <[email protected]> CommitterDate: Fri Dec 2 12:25:10 2022 -0600
device_id: fix segfault verifying serial for non-pv
The recent change that verifies sys_serial system.devices entries using the PVID did not exclude non-PV devices from being checked. The verification code would attempt to use du->pvid which was null for the non-PVs causing a segfault.
--- lib/device/device_id.c | 6 ++- test/shell/devicesfile-serial.sh | 79 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 2 deletions(-)
lib/device/device_id.c +4 -2
@@ -2239,8 +2239,8 @@ void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs,* number is correct, since serial numbers may not be unique. * Search for the PVID on other devs in device_ids_check_serial. */ -if ((du->idtype ==DEV_ID_TYPE_SYS_SERIAL ) && - (!du->pvid ||memcmp (dev->pvid, du->pvid,ID_LEN ))) { +if ((du->idtype ==DEV_ID_TYPE_SYS_SERIAL ) && du->pvid && +memcmp (dev->pvid, du->pvid,ID_LEN )) {log_debug ("suspect device id serial %s for %s" , du->idname,dev_name (dev));str_list_add (cmd->mem, &cmd->device_ids_check_serial,dm_pool_strdup (cmd->mem, du->idname)); *device_ids_invalid =1 ;
@@ -2573,6 +2573,8 @@ void device_ids_check_serial(struct cmd_context *cmd, struct dm_list *scan_devs, dm_list_iterate_items(dul, &dus_check) {if (!dul->du->dev)continue ; +if (!dul->du->pvid) +continue ;/* save previously matched devs so they can be dropped from lvmcache at the end if they are no longer used */ if (!(dil =dm_pool_zalloc (cmd->mem,sizeof (*dil))))
test/shell/devicesfile-serial.sh +79 -0
85 lines not on this page · raw message