https://gcc.gnu.org/g:c1c66ede4052c2697f3dd17b80f8b80ff3fc2368
commit r17-1994-gc1c66ede4052c2697f3dd17b80f8b80ff3fc2368 Author: Thomas Schwinge <[email protected]> Date: Tue Jun 30 08:55:08 2026 +0200 OpenMP: Add omp_get_device_distances routine: Gracefully handle failure to open Linux sysfs file for NUMA node [PR125877] Fix-up for commit 8af1592882509fbead16e30fd2d056330a9609e4 "OpenMP: Add omp_get_device_distances routine [PR125877]". Without this, 'libgomp/config/linux/numa.c:gomp_get_numa_distance' faults when trying to 'fscanf' from the null pointer upon 'fopen' failure. PR libgomp/125877 libgomp/ * config/linux/numa.c (gomp_get_numa_distance): Gracefully handle failure to open Linux sysfs file for NUMA node. Diff: --- libgomp/config/linux/numa.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libgomp/config/linux/numa.c b/libgomp/config/linux/numa.c index d43b34b98dd1..a3d84870e6e8 100644 --- a/libgomp/config/linux/numa.c +++ b/libgomp/config/linux/numa.c @@ -85,6 +85,11 @@ gomp_get_numa_distance (int node1, int node2) return -1; int distance = -1; FILE *in = fopen (filename, "r"); + if (!in) + { + free (numa_distances); + return -1; + } for (int j = 0; j < cnt; j++) { fscanf (in, "%d", &distance);
