Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932659AbcLIFGL (ORCPT ); Fri, 9 Dec 2016 00:06:11 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:55178 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932170AbcLIFGK (ORCPT ); Fri, 9 Dec 2016 00:06:10 -0500 X-AuditID: cbfee61b-f796f6d000004092-a5-584a3bc03bac From: Jaewon Kim To: gregkh@linuxfoundation.org Cc: labbott@redhat.com, sumit.semwal@linaro.org, tixy@linaro.org, prime.zeng@huawei.com, tranmanphong@gmail.com, fabio.estevam@freescale.com, ccross@android.com, rebecca@android.com, benjamin.gaignard@linaro.org, arve@android.com, riandrews@android.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, Jaewon Kim Subject: [PATCH] staging: android: ion: return -ENOMEM in ion_cma_heap allocation failure Date: Fri, 09 Dec 2016 14:05:30 +0900 Message-id: <1481259930-4620-2-git-send-email-jaewon31.kim@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1481259930-4620-1-git-send-email-jaewon31.kim@samsung.com> References: <1481259930-4620-1-git-send-email-jaewon31.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsVy+t9jAd0D1l4RBg0bBC3e/73PZtF06BSb xfaN31gtZnXpWjQvXs9m0b15JqNF7/tXTBYr9/xgsri8aw6bxb01/1ktJs9ez2xxY3KhxetN fxktTt39zG6xcP59dovevk4WBwGPbbu3sXr8O9zP5LFz1l12j5Yjb1k9Nn2axO5x59oeNo/9 c9ewe7zfd5XNo2/LKkaPz5vkArii3GwyUhNTUosUUvOS81My89JtlUJD3HQtlBTyEnNTbZUi dH1DgpQUyhJzSoE8IwM04OAc4B6spG+X4JYx4eZ75oJX3BVrW34xNTB+4+xi5OSQEDCRmLvw CwuELSZx4d56ti5GLg4hgaWMEvtvbWKFcJqYJA6097OCVLEJaEu8XzAJzBYRkJN4cvsPM0gR s8B3Jom/t04xgySEBaIlvp3fxQhiswioSlz59gdoLAcHr4C7xJl5eRDb5CROHpsMNodTwEPi 6P4NYK1CQCW3r15jmcDIu4CRYRWjRGpBckFxUnquUV5quV5xYm5xaV66XnJ+7iZGcHQ9k97B eHiX+yFGAQ5GJR7eAwWeEUKsiWXFlbmHGCU4mJVEeM9bekUI8aYkVlalFuXHF5XmpBYfYjQF umsis5Rocj4w8vNK4g1NzE3MjQ0szC0tTYyUxHkbZz8LFxJITyxJzU5NLUgtgulj4uCUamCs zjQxfbH/OL9Z6izWIIvGeTmqfwRen/Q8LZD0/4iSW3Jo27PrLhYmCy/+2Zi14fv1AyH6T7ib fN5LnKhfnvV/y2H1NHWvf1M+2p+9vcjLKrRz9ys+TcX9V+9OKPS3ajthYqDc6dHyL4XhE7fw E+Mj63RX5BSXBr9P+2xsZpfL7SicGvNer0OJpTgj0VCLuag4EQBMZ9XRxAIAAA== X-MTR: 20000000000000000@CPGS Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1468 Lines: 44 Initial Commit 349c9e138551 ("gpu: ion: add CMA heap") returns -1 in allocation failure. The returned value is passed up to userspace through ioctl. So user can misunderstand error reason as -EPERM(1) rather than -ENOMEM(12). This patch simply changed this to return -ENOMEM. Signed-off-by: Jaewon Kim --- drivers/staging/android/ion/ion_cma_heap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c index 6c7de74..22b9582 100644 --- a/drivers/staging/android/ion/ion_cma_heap.c +++ b/drivers/staging/android/ion/ion_cma_heap.c @@ -24,8 +24,6 @@ #include "ion.h" #include "ion_priv.h" -#define ION_CMA_ALLOCATE_FAILED -1 - struct ion_cma_heap { struct ion_heap heap; struct device *dev; @@ -59,7 +57,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, info = kzalloc(sizeof(struct ion_cma_buffer_info), GFP_KERNEL); if (!info) - return ION_CMA_ALLOCATE_FAILED; + return -ENOMEM; info->cpu_addr = dma_alloc_coherent(dev, len, &(info->handle), GFP_HIGHUSER | __GFP_ZERO); @@ -88,7 +86,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, dma_free_coherent(dev, len, info->cpu_addr, info->handle); err: kfree(info); - return ION_CMA_ALLOCATE_FAILED; + return -ENOMEM; } static void ion_cma_free(struct ion_buffer *buffer) -- 1.9.1