diff mbox series

[v3,1/3] linux-generic: pool: validate params before creating pool

Message ID 1513026020-24993-2-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v3,1/3] linux-generic: pool: validate params before creating pool | expand

Commit Message

Github ODP bot Dec. 11, 2017, 9 p.m. UTC
From: Bill Fischofer <bill.fischofer@linaro.org>


Enhance the check_params() routine to verify that params != NULL
prior to dereferencing it.

This fixes Bug https://bugs.linaro.org/show_bug.cgi?id=3465

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

---
/** Email created from pull request 325 (Bill-Fischofer-Linaro:bug3465)
 ** https://github.com/Linaro/odp/pull/325
 ** Patch: https://github.com/Linaro/odp/pull/325.patch
 ** Base sha: 6881620135a179911a5839d4be97423a8d80e5ab
 ** Merge commit sha: 031d1e139f0c3b25b906fc9c79120fd327a758c4
 **/
 platform/linux-generic/odp_pool.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c
index c0dd41ebf..b3c652360 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -352,11 +352,6 @@  static odp_pool_t pool_create(const char *name, odp_pool_param_t *params,
 	const char *postfix = "_uarea";
 	char uarea_name[ODP_POOL_NAME_LEN + sizeof(postfix)];
 
-	if (params == NULL) {
-		ODP_ERR("No params");
-		return ODP_POOL_INVALID;
-	}
-
 	align = 0;
 
 	if (params->type == ODP_POOL_BUFFER)
@@ -533,7 +528,7 @@  static int check_params(odp_pool_param_t *params)
 {
 	odp_pool_capability_t capa;
 
-	if (odp_pool_capability(&capa) < 0)
+	if (!params || odp_pool_capability(&capa) < 0)
 		return -1;
 
 	switch (params->type) {
@@ -603,7 +598,7 @@  odp_pool_t odp_pool_create(const char *name, odp_pool_param_t *params)
 	if (check_params(params))
 		return ODP_POOL_INVALID;
 
-	if (params && (params->type == ODP_POOL_PACKET))
+	if (params->type == ODP_POOL_PACKET)
 		shm_flags = ODP_SHM_PROC;
 
 	return pool_create(name, params, shm_flags);