From b96845b63204336a0e05a1b1c27cb02d626d4f5d Mon Sep 17 00:00:00 2001 From: Uglymotha Date: Tue, 5 Nov 2024 01:44:38 +0100 Subject: [PATCH] Verify parent_dev before calling udev_device_get_sysattr_value Not all udev devices have parent devices. Calling udev_device_get_ functions yield an assertion error if called with a NULL pointer. Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Sietse Co-authored-by: Sietse Closes #16705 Closes #16717 --- cmd/zed/zed_disk_event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/zed/zed_disk_event.c b/cmd/zed/zed_disk_event.c index 32a8789d3001..4a2b7398e922 100644 --- a/cmd/zed/zed_disk_event.c +++ b/cmd/zed/zed_disk_event.c @@ -139,7 +139,8 @@ dev_event_nvlist(struct udev_device *dev) * is /dev/sda. */ struct udev_device *parent_dev = udev_device_get_parent(dev); - if ((value = udev_device_get_sysattr_value(parent_dev, "size")) + if (parent_dev != NULL && + (value = udev_device_get_sysattr_value(parent_dev, "size")) != NULL) { uint64_t numval = DEV_BSIZE;