The helper methods for getting integer properties ignore a missing property setting its value to zero. This lack of error reporting resulted in missing the regression handling hotplug of USB devices with the vendor and model IDs getting set to zero silently. The few callers which relied on this silent defaulting have been fixed, so now we can report fatal errors immediately. Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- src/node_device/node_device_udev.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index a25babcf0d..86b0ece5c0 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -169,10 +169,17 @@ udevGetIntProperty(struct udev_device *udev_device, const char *str = NULL; str = udevGetDeviceProperty(udev_device, property_key); + if (!str) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Missing udev property '%s' on '%s'"), + property_key, udev_device_get_sysname(udev_device)); + return -1; + } - if (str && virStrToLong_i(str, NULL, base, value) < 0) { + if (virStrToLong_i(str, NULL, base, value) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to convert '%s' to int"), str); + _("Failed to parse int '%s' from udev property '%s' on '%s'"), + str, property_key, udev_device_get_sysname(udev_device)); return -1; } return 0; @@ -188,10 +195,17 @@ udevGetUintProperty(struct udev_device *udev_device, const char *str = NULL; str = udevGetDeviceProperty(udev_device, property_key); + if (!str) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Missing udev property '%s' on '%s'"), + property_key, udev_device_get_sysname(udev_device)); + return -1; + } - if (str && virStrToLong_ui(str, NULL, base, value) < 0) { + if (virStrToLong_ui(str, NULL, base, value) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to convert '%s' to int"), str); + _("Failed to parse uint '%s' from udev property '%s' on '%s'"), + str, property_key, udev_device_get_sysname(udev_device)); return -1; } return 0; -- 2.28.0