Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753485AbcLMQFP (ORCPT ); Tue, 13 Dec 2016 11:05:15 -0500 Received: from mail-qk0-f169.google.com ([209.85.220.169]:34390 "EHLO mail-qk0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932602AbcLMQEL (ORCPT ); Tue, 13 Dec 2016 11:04:11 -0500 Subject: Re: [PATCH] staging: android: ion: return -ENOMEM in ion_cma_heap allocation failure To: Jaewon Kim , gregkh@linuxfoundation.org References: <1481259930-4620-1-git-send-email-jaewon31.kim@samsung.com> <1481259930-4620-2-git-send-email-jaewon31.kim@samsung.com> Cc: 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 From: Laura Abbott Message-ID: Date: Tue, 13 Dec 2016 08:04:06 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1481259930-4620-2-git-send-email-jaewon31.kim@samsung.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1654 Lines: 48 On 12/08/2016 09:05 PM, Jaewon Kim wrote: > 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) > Happy to see cleanup Acked-by: Laura Abbott