From 58f0e25d0d882aaddbac32a8f3858c2d476b56d3 Mon Sep 17 00:00:00 2001 From: John Stultz Date: Thu, 18 Mar 2021 22:59:34 +0000 Subject: [PATCH] ANDROID: dma-buf: Fix error path on system heaps use of the page pool Daniel Mentz relayed to me that Janghyuck Kim noted that dma_buf_page_pool_create() returns NULL on error, so the IS_ERR() check on the return value will never be true. This patch fixes up the checking so we look for NULL instead and properly return ENOMEM in that case. Cc: Daniel Mentz Reported-by: Janghyuck Kim Signed-off-by: John Stultz Fixes: 23762f02e172 ("ANDROID: dma-buf: system_heap: Add pagepool support to system heap") Change-Id: Ia428e262cda5cc6bd39a3fbcddade7877473a563 --- drivers/dma-buf/heaps/system_heap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c index 5b09a4c16be6..c203eddfb772 100644 --- a/drivers/dma-buf/heaps/system_heap.c +++ b/drivers/dma-buf/heaps/system_heap.c @@ -534,13 +534,13 @@ static int system_heap_create(void) for (i = 0; i < NUM_ORDERS; i++) { pools[i] = dmabuf_page_pool_create(order_flags[i], orders[i]); - if (IS_ERR(pools[i])) { + if (!pools[i]) { int j; pr_err("%s: page pool creation failed!\n", __func__); for (j = 0; j < i; j++) dmabuf_page_pool_destroy(pools[j]); - return PTR_ERR(pools[i]); + return -ENOMEM; } }