Message ID | 20180827064233.3218-4-honli@redhat.com (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | Hal Rosenstock |
Headers | show |
Series | [1/5] Adjust BuildRequires for covscan | expand |
On 8/27/2018 2:42 AM, Honggang LI wrote: > From: Honggang Li <honli@redhat.com> > > 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@redhat.com> Thanks. Applied. -- Hal
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;