libibnetdisc: Add NULL check after malloc in ibnetdisc.c

Add NULL pointer checks after malloc() calls to prevent potential
segmentation faults when memory allocation fails.

Three instances in ibnetdisc.c allocate ni_cbdata structures without
checking if malloc() returns NULL before dereferencing the pointer:
- Line 262 in mlnx_ext_port_info_err()
- Line 311 in recv_mlnx_ext_port_info()
- Line 422 in recv_port_info()

This could cause crashes under memory pressure conditions.

Signed-off-by: Dai Yanlong <daiyanlong@kylinos.cn>
diff --git a/libibnetdisc/ibnetdisc.c b/libibnetdisc/ibnetdisc.c
index 1a24bcd..1563d87 100644
--- a/libibnetdisc/ibnetdisc.c
+++ b/libibnetdisc/ibnetdisc.c
@@ -260,6 +260,8 @@
 
 		if (rc > 0) {
 			struct ni_cbdata * cbdata = malloc(sizeof(*cbdata));
+			if (!cbdata)
+				return -1;
 			cbdata->node = node;
 			cbdata->port_num = port_num;
 			query_node_info(engine, &path, cbdata);
@@ -309,6 +311,8 @@
 
 		if (rc > 0) {
 			struct ni_cbdata * cbdata = malloc(sizeof(*cbdata));
+			if (!cbdata)
+				return -1;
 			cbdata->node = node;
 			cbdata->port_num = port_num;
 			query_node_info(engine, &path, cbdata);
@@ -420,6 +424,8 @@
 
 		if (rc > 0) {
 			struct ni_cbdata * cbdata = malloc(sizeof(*cbdata));
+			if (!cbdata)
+				return -1;
 			cbdata->node = node;
 			cbdata->port_num = port_num;
 			query_node_info(engine, &path, cbdata);