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
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 <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Sietse <[email protected]>
Co-authored-by: Sietse <[email protected]>
Closes #16705 
Closes #16717
  • Loading branch information
Uglymotha authored Nov 5, 2024
1 parent b16e096 commit c8aed9f
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 c8aed9f

Please sign in to comment.