libibnetdisc: guard against NULL remoteport in chassis grouping

[ Upstream commit 66fcb26cae23b9b8bc94b8fb46f37e896ccc1bbc ]

fill_voltaire_chassis_record()'s router branch dereferences
port->remoteport->node without checking that the port has a remote port,
unlike the other port loops in this file. An incomplete fabric can
therefore crash during group_nodes().

Add the missing port->remoteport check.

Fixes: a626de1abde7 ("Create a new library libibnetdisc")
Signed-off-by: Jonathan Süssemilch Poulain <jpoulain@coreweave.com>
Signed-off-by: Nicolas Morey <nmorey@suse.com>
diff --git a/libibnetdisc/chassis.c b/libibnetdisc/chassis.c
index bc1a8af..d34d341 100644
--- a/libibnetdisc/chassis.c
+++ b/libibnetdisc/chassis.c
@@ -773,7 +773,8 @@
 		/* find the remote node */
 		for (p = 1; p <= node->numports; p++) {
 			port = node->ports[p];
-			if (port && is_spine(port->remoteport->node))
+			if (port && port->remoteport &&
+			    is_spine(port->remoteport->node))
 				get_router_slot(node, port->remoteport);
 		}
 	else if (is_spine(node)) {