diff options
author | John Baldwin <jhb@FreeBSD.org> | 2025-01-29 15:03:59 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2025-01-29 15:03:59 +0000 |
commit | 7554746c43c50d99d15bb63ff43c90e561a9792e (patch) | |
tree | 3717f359180c731022ad1f5c49b9d5fca509e588 /lib | |
parent | c06b504def0ce10840d9415f204128b61210b5eb (diff) |
libdevinfo: Avoid false positives for the root0 sentinel value
Previously, a NULL pointer value was used to request the root0 device
at the top of the device tree. However, this meant that resource
ranges from a rman with a NULL device pointer were annotated as being
owned by root0 instead of being unowned. Switch to a different value
for root0's sentinel to avoid the clash.
Since this is an ABI change, bump the SHLIB_MAJOR for libdevinfo to 7.
Reported by: jrtc27
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D48675
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libdevinfo/Makefile | 2 | ||||
-rw-r--r-- | lib/libdevinfo/devinfo.c | 2 | ||||
-rw-r--r-- | lib/libdevinfo/devinfo.h | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/lib/libdevinfo/Makefile b/lib/libdevinfo/Makefile index 41e17f7de0be..b74806e42672 100644 --- a/lib/libdevinfo/Makefile +++ b/lib/libdevinfo/Makefile @@ -14,7 +14,7 @@ MLINKS+=devinfo.3 devinfo_foreach_device_resource.3 MLINKS+=devinfo.3 devinfo_foreach_rman_resource.3 MLINKS+=devinfo.3 devinfo_foreach_rman.3 -SHLIB_MAJOR= 6 +SHLIB_MAJOR= 7 WARNS?= 3 diff --git a/lib/libdevinfo/devinfo.c b/lib/libdevinfo/devinfo.c index 115e7ea76602..65a26d871371 100644 --- a/lib/libdevinfo/devinfo.c +++ b/lib/libdevinfo/devinfo.c @@ -420,7 +420,7 @@ devinfo_handle_to_device(devinfo_handle_t handle) */ if (handle == DEVINFO_ROOT_DEVICE) { TAILQ_FOREACH(dd, &devinfo_dev, dd_link) - if (dd->dd_dev.dd_parent == DEVINFO_ROOT_DEVICE) + if (dd->dd_dev.dd_parent == 0) return(&dd->dd_dev); return(NULL); } diff --git a/lib/libdevinfo/devinfo.h b/lib/libdevinfo/devinfo.h index 07e2043d43ce..0d02a75195d3 100644 --- a/lib/libdevinfo/devinfo.h +++ b/lib/libdevinfo/devinfo.h @@ -34,7 +34,7 @@ #include <sys/bus.h> typedef __uintptr_t devinfo_handle_t; -#define DEVINFO_ROOT_DEVICE ((devinfo_handle_t)0) +#define DEVINFO_ROOT_DEVICE ((devinfo_handle_t)-1) typedef enum device_state devinfo_state_t; |