|
|
cfe731 |
From 1da99335fa1b1efd086e537682203ff65a09bed9 Mon Sep 17 00:00:00 2001
|
|
|
cfe731 |
From: Hal Rosenstock <hal@mellanox.com>
|
|
|
cfe731 |
Date: Tue, 22 Jan 2019 11:28:47 +0800
|
|
|
cfe731 |
Subject: [PATCH 5/5] osm_[link_mgr trap_rcv].c: Check the return value of
|
|
|
cfe731 |
osm_get_port_by_guid
|
|
|
cfe731 |
|
|
|
cfe731 |
Issue was found by Coverity.
|
|
|
cfe731 |
|
|
|
cfe731 |
3. Defect type: NULL_RETURNS
|
|
|
cfe731 |
8. opensm-3.3.21/opensm/osm_trap_rcv.c:254: returned_null: "osm_get_port_by_guid" returns null (checked 46 out of 49 times).
|
|
|
cfe731 |
9. opensm-3.3.21/opensm/osm_trap_rcv.c:254: var_assigned: Assigning: "p_port" = null return value from "osm_get_port_by_guid".
|
|
|
cfe731 |
10. opensm-3.3.21/opensm/osm_trap_rcv.c:256: dereference: Dereferencing a null pointer "p_port".
|
|
|
cfe731 |
11. opensm-3.3.21/opensm/osm_congestion_control.c:678: example_assign: Example 1: Assigning: "p_port" = return value from "osm_get_port_by_guid(p_cc->subn, port_guid)".
|
|
|
cfe731 |
12. opensm-3.3.21/opensm/osm_congestion_control.c:679: example_checked: Example 1 (cont.): "p_port" has its value checked in "p_port".
|
|
|
cfe731 |
13. opensm-3.3.21/opensm/osm_drop_mgr.c:91: example_assign: Example 2: Assigning: "p_remote_port" = return value from "osm_get_port_by_guid(sm->p_subn, p_remote_physp->port_guid)".
|
|
|
cfe731 |
14. opensm-3.3.21/opensm/osm_drop_mgr.c:94: example_checked: Example 2 (cont.): "p_remote_port" has its value checked in "p_remote_port".
|
|
|
cfe731 |
15. opensm-3.3.21/opensm/osm_guid_info_rcv.c:105: example_assign: Example 3: Assigning: "p_port" = return value from "osm_get_port_by_guid(sm->p_subn, port_guid)".
|
|
|
cfe731 |
16. opensm-3.3.21/opensm/osm_guid_info_rcv.c:106: example_checked: Example 3 (cont.): "p_port" has its value checked in "p_port".
|
|
|
cfe731 |
17. opensm-3.3.21/opensm/osm_inform.c:434: example_assign: Example 4: Assigning: "p_src_port" = return value from "osm_get_port_by_guid(p_subn, source_gid.unicast.interface_id)".
|
|
|
cfe731 |
18. opensm-3.3.21/opensm/osm_inform.c:436: example_checked: Example 4 (cont.): "p_src_port" has its value checked in "p_src_port".
|
|
|
cfe731 |
19. opensm-3.3.21/opensm/osm_lid_mgr.c:1112: example_assign: Example 5: Assigning: "p_port" = return value from "osm_get_port_by_guid(p_mgr->p_subn, p_mgr->p_subn->sm_port_guid)".
|
|
|
cfe731 |
20. opensm-3.3.21/opensm/osm_lid_mgr.c:1114: example_checked: Example 5 (cont.): "p_port" has its value checked in "p_port".
|
|
|
cfe731 |
// 1112| p_port = osm_get_port_by_guid(p_mgr->p_subn,
|
|
|
cfe731 |
// 1113| p_mgr->p_subn->sm_port_guid);
|
|
|
cfe731 |
// 1114|-> if (!p_port) {
|
|
|
cfe731 |
// 1115| OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0308: "
|
|
|
cfe731 |
// 1116| "Can't acquire SM's port object, GUID 0x%016" PRIx64
|
|
|
cfe731 |
|
|
|
cfe731 |
4. Defect type: NULL_RETURNS
|
|
|
cfe731 |
3. opensm-3.3.21/opensm/osm_link_mgr.c:126: returned_null: "osm_get_port_by_guid" returns null (checked 46 out of 49 times).
|
|
|
cfe731 |
4. opensm-3.3.21/opensm/osm_link_mgr.c:126: var_assigned: Assigning: "p_port" = null return value from "osm_get_port_by_guid".
|
|
|
cfe731 |
5. opensm-3.3.21/opensm/osm_link_mgr.c:128: dereference: Dereferencing a null pointer "p_port".
|
|
|
cfe731 |
6. opensm-3.3.21/opensm/osm_congestion_control.c:678: example_assign: Example 1: Assigning: "p_port" = return value from "osm_get_port_by_guid(p_cc->subn, port_guid)".
|
|
|
cfe731 |
7. opensm-3.3.21/opensm/osm_congestion_control.c:679: example_checked: Example 1 (cont.): "p_port" has its value checked in "p_port".
|
|
|
cfe731 |
8. opensm-3.3.21/opensm/osm_drop_mgr.c:91: example_assign: Example 2: Assigning: "p_remote_port" = return value from "osm_get_port_by_guid(sm->p_subn, p_remote_physp->port_guid)".
|
|
|
cfe731 |
9. opensm-3.3.21/opensm/osm_drop_mgr.c:94: example_checked: Example 2 (cont.): "p_remote_port" has its value checked in "p_remote_port".
|
|
|
cfe731 |
10. opensm-3.3.21/opensm/osm_guid_info_rcv.c:105: example_assign: Example 3: Assigning: "p_port" = return value from "osm_get_port_by_guid(sm->p_subn, port_guid)".
|
|
|
cfe731 |
11. opensm-3.3.21/opensm/osm_guid_info_rcv.c:106: example_checked: Example 3 (cont.): "p_port" has its value checked in "p_port".
|
|
|
cfe731 |
12. opensm-3.3.21/opensm/osm_inform.c:434: example_assign: Example 4: Assigning: "p_src_port" = return value from "osm_get_port_by_guid(p_subn, source_gid.unicast.interface_id)".
|
|
|
cfe731 |
13. opensm-3.3.21/opensm/osm_inform.c:436: example_checked: Example 4 (cont.): "p_src_port" has its value checked in "p_src_port".
|
|
|
cfe731 |
14. opensm-3.3.21/opensm/osm_lid_mgr.c:1112: example_assign: Example 5: Assigning: "p_port" = return value from "osm_get_port_by_guid(p_mgr->p_subn, p_mgr->p_subn->sm_port_guid)".
|
|
|
cfe731 |
15. opensm-3.3.21/opensm/osm_lid_mgr.c:1114: example_checked: Example 5 (cont.): "p_port" has its value checked in "p_port".
|
|
|
cfe731 |
// 1112| p_port = osm_get_port_by_guid(p_mgr->p_subn,
|
|
|
cfe731 |
// 1113| p_mgr->p_subn->sm_port_guid);
|
|
|
cfe731 |
// 1114|-> if (!p_port) {
|
|
|
cfe731 |
// 1115| OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0308: "
|
|
|
cfe731 |
// 1116| "Can't acquire SM's port object, GUID 0x%016" PRIx64
|
|
|
cfe731 |
|
|
|
cfe731 |
Pointed-out-by: Honggang Li <honli@redhat.com>
|
|
|
cfe731 |
|
|
|
cfe731 |
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
|
|
|
cfe731 |
Signed-off-by: Honggang Li <honli@redhat.com>
|
|
|
cfe731 |
---
|
|
|
cfe731 |
opensm/osm_link_mgr.c | 2 ++
|
|
|
cfe731 |
opensm/osm_trap_rcv.c | 13 ++++++++++++-
|
|
|
cfe731 |
2 files changed, 14 insertions(+), 1 deletion(-)
|
|
|
cfe731 |
|
|
|
cfe731 |
diff --git a/opensm/osm_link_mgr.c b/opensm/osm_link_mgr.c
|
|
|
cfe731 |
index 64ddaf7d1560..ca69375378a0 100644
|
|
|
cfe731 |
--- a/opensm/osm_link_mgr.c
|
|
|
cfe731 |
+++ b/opensm/osm_link_mgr.c
|
|
|
cfe731 |
@@ -112,6 +112,7 @@ static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp,
|
|
|
cfe731 |
OSM_LOG_ENTER(sm->p_log);
|
|
|
cfe731 |
|
|
|
cfe731 |
p_node = osm_physp_get_node_ptr(p_physp);
|
|
|
cfe731 |
+ CL_ASSERT(p_node);
|
|
|
cfe731 |
|
|
|
cfe731 |
p_old_pi = &p_physp->port_info;
|
|
|
cfe731 |
|
|
|
cfe731 |
@@ -125,6 +126,7 @@ static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp,
|
|
|
cfe731 |
if (!p_pi->base_lid) {
|
|
|
cfe731 |
p_port = osm_get_port_by_guid(sm->p_subn,
|
|
|
cfe731 |
osm_physp_get_port_guid(p_physp));
|
|
|
cfe731 |
+ CL_ASSERT(p_port);
|
|
|
cfe731 |
p_pi->base_lid = p_port->lid;
|
|
|
cfe731 |
sm->lid_mgr.dirty = TRUE;
|
|
|
cfe731 |
send_set = TRUE;
|
|
|
cfe731 |
diff --git a/opensm/osm_trap_rcv.c b/opensm/osm_trap_rcv.c
|
|
|
cfe731 |
index 51a836981e8c..ba50d9f2fcdb 100644
|
|
|
cfe731 |
--- a/opensm/osm_trap_rcv.c
|
|
|
cfe731 |
+++ b/opensm/osm_trap_rcv.c
|
|
|
cfe731 |
@@ -253,7 +253,16 @@ static int disable_port(osm_sm_t *sm, osm_physp_t *p)
|
|
|
cfe731 |
if (!pi->base_lid) {
|
|
|
cfe731 |
p_port = osm_get_port_by_guid(sm->p_subn,
|
|
|
cfe731 |
osm_physp_get_port_guid(p));
|
|
|
cfe731 |
- pi->base_lid = p_port->lid;
|
|
|
cfe731 |
+ if (p_port)
|
|
|
cfe731 |
+ pi->base_lid = p_port->lid;
|
|
|
cfe731 |
+ else {
|
|
|
cfe731 |
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
|
|
|
cfe731 |
+ "ERR 3804: Port 0x%" PRIx64
|
|
|
cfe731 |
+ " not found, port set failed\n",
|
|
|
cfe731 |
+ cl_ntoh64(osm_physp_get_port_guid(p)));
|
|
|
cfe731 |
+ status = IB_ERROR;
|
|
|
cfe731 |
+ goto EXIT;
|
|
|
cfe731 |
+ }
|
|
|
cfe731 |
}
|
|
|
cfe731 |
pi->master_sm_base_lid = sm->p_subn->sm_base_lid;
|
|
|
cfe731 |
}
|
|
|
cfe731 |
@@ -263,6 +272,8 @@ static int disable_port(osm_sm_t *sm, osm_physp_t *p)
|
|
|
cfe731 |
cl_hton32(osm_physp_get_port_num(p)),
|
|
|
cfe731 |
FALSE, m_key,
|
|
|
cfe731 |
0, CL_DISP_MSGID_NONE, &context);
|
|
|
cfe731 |
+
|
|
|
cfe731 |
+EXIT:
|
|
|
cfe731 |
return status;
|
|
|
cfe731 |
}
|
|
|
cfe731 |
|
|
|
cfe731 |
--
|
|
|
cfe731 |
2.15.0-rc1
|
|
|
cfe731 |
|