Message ID | 20180828014834.3046-1-honli@redhat.com (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | Hal Rosenstock |
Headers | show |
Series | [1/5] osmt_service.c: fix resource leak in osmt_get_all_services_and_check_names | expand |
On 8/27/2018 9:48 PM, Honggang LI wrote: > From: Honggang Li <honli@redhat.com> > > Issue was found by Coverity. > > Error: RESOURCE_LEAK (CWE-772): [#def12] > opensm-3.3.20/osmtest/osmt_service.c:988: alloc_fn: Storage is returned from allocation function "malloc". > opensm-3.3.20/osmtest/osmt_service.c:988: var_assign: Assigning: "p_checked_names" = storage returned from "malloc(1UL * num_of_valid_names)". > opensm-3.3.20/osmtest/osmt_service.c:1091: leaked_storage: Variable "p_checked_names" going out of scope leaks the storage it points to. > |# 1089| > |# 1090| OSM_LOG_EXIT(&p_osmt->log); > |# 1091|-> return status; > |# 1092| } > |# 1093| #endif > > Signed-off-by: Honggang Li <honli@redhat.com> Thanks. Applied. -- Hal
diff --git a/osmtest/osmt_service.c b/osmtest/osmt_service.c index 5ca2ecaa..eeda1ac9 100644 --- a/osmtest/osmt_service.c +++ b/osmtest/osmt_service.c @@ -1087,6 +1087,7 @@ Exit: context.result.p_result_madw = NULL; } + free(p_checked_names); OSM_LOG_EXIT(&p_osmt->log); return status; }