From: Honggang Li <honli@xxxxxxxxxx> Issue was found by Coverity. Error: RESOURCE_LEAK (CWE-772): [#def11] opensm-3.3.20/opensm/osm_qos_parser_y.y:996: alloc_fn: Storage is returned from allocation function "malloc". opensm-3.3.20/opensm/osm_qos_parser_y.y:996: var_assign: Assigning: "range_arr" = storage returned from "malloc(8UL)". opensm-3.3.20/opensm/osm_qos_parser_y.y:1006: noescape: Resource "range_arr" is not freed or pointed-to in "__validate_pkeys". opensm-3.3.20/opensm/osm_qos_parser_y.y:3111:42: noescape: "__validate_pkeys(uint64_t **, unsigned int, boolean_t)" does not free or save its parameter "range_arr". opensm-3.3.20/opensm/osm_qos_parser_y.y:1007: leaked_storage: Variable "range_arr" going out of scope leaks the storage it points to. |# 1005| */ |# 1006| if (__validate_pkeys(range_arr, 1, TRUE)) |# 1007|-> return 1; |# 1008| |# 1009| p_current_qos_match_rule->pkey_range_arr = range_arr; Signed-off-by: Honggang Li <honli@xxxxxxxxxx> --- opensm/osm_qos_parser_y.y | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/opensm/osm_qos_parser_y.y b/opensm/osm_qos_parser_y.y index e0f6580c..12466956 100644 --- a/opensm/osm_qos_parser_y.y +++ b/opensm/osm_qos_parser_y.y @@ -1003,8 +1003,11 @@ qos_ulp: TK_ULP_DEFAULT single_number { * we still need to validate it by checking that it has * at least two full members. Otherwise IPoIB won't work. */ - if (__validate_pkeys(range_arr, 1, TRUE)) + if (__validate_pkeys(range_arr, 1, TRUE)) { + free(range_arr[0]); + free(range_arr); return 1; + } p_current_qos_match_rule->pkey_range_arr = range_arr; p_current_qos_match_rule->pkey_range_len = 1; -- 2.14.4