From 89ea28116a0a90f954ea2942afb5a1bf293bab9b Mon Sep 17 00:00:00 2001 From: Sandeep Patil Date: Mon, 15 Jul 2019 17:29:33 -0700 Subject: [PATCH] libion: Add missing error checks for input parameters to APIs. The errors were caught by ion-unit-tests. Make sure we fix them before we start running the tests in automation etc. Bug: 133508579 Test: ion-unit-tests Change-Id: I7ebecfa037767481ee7f2b30e2923c84ebc352bf Signed-off-by: Sandeep Patil --- libion/ion.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libion/ion.c b/libion/ion.c index b8de5a411..1ecfc785a 100644 --- a/libion/ion.c +++ b/libion/ion.c @@ -152,6 +152,8 @@ int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask, unsig ion_user_handle_t handle; int ret; + if (!handle_fd) return -EINVAL; + if (!ion_is_legacy(fd)) { struct ion_new_allocation_data data = { .len = len, @@ -201,6 +203,7 @@ int ion_query_heap_cnt(int fd, int* cnt) { int ret; struct ion_heap_query query; + if (!cnt) return -EINVAL; memset(&query, 0, sizeof(query)); ret = ion_ioctl(fd, ION_IOC_HEAP_QUERY, &query);