Skip to content

Commit

Permalink
Verify parent_dev before calling udev_device_get_sysattr_value
Browse files Browse the repository at this point in the history
Fixes: #16705

Not all udev devices have parent devices.
Calling udev_device_get_ functions yield an assertion error
if called with a NULL pointer.

Changes to be committed:
	modified:   cmd/zed/zed_disk_event.c

Signed-off-by: Sietse <sietse@wizdom.nu>
  • Loading branch information
Sietse committed Nov 4, 2024
1 parent 91bd12d commit 2c2cffa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/zed/zed_disk_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 2c2cffa

Please sign in to comment.