[PATCH 1/5] osmt_service.c: fix resource leak in osmt_get_all_services_and_check_names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Honggang Li <honli@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 osmtest/osmt_service.c | 1 +
 1 file changed, 1 insertion(+)

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;
 }
-- 
2.14.4




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux