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
This commit is contained in:
John Baldwin 2025-01-29 10:03:59 -05:00
parent c06b504def
commit 7554746c43
4 changed files with 6 additions and 3 deletions

View file

@ -51,6 +51,9 @@
# xargs -n1 | sort | uniq -d;
# done
# 2025xxxx: libdevinfo bumped to version 7
OLD_LIBS+=lib/libdevinfo.so.6
# 20250123: Remove gvinum(8)
OLD_FILES+=sbin/gvinum
OLD_FILES+=usr/share/man/man8/gvinum.8.gz

View file

@ -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

View file

@ -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);
}

View file

@ -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;