Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1333352

Re: [PATCH] goldfish: Return correct error code

From Julia Lawall <julia.lawall@lip6.fr>
Newsgroups linux.kernel
Subject Re: [PATCH] goldfish: Return correct error code
Date 2016-02-13 20:10 +0100
Message-ID <r1NJT-xX-5@gated-at.bofh.it> (permalink)
References <r1JGi-66L-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On Sat, 13 Feb 2016, Amitoj Kaur Chawla wrote:

> The return value of devm_kzalloc on failure of allocation of memory
> should be -ENOMEM and not -1.
> 
> Found using Coccinelle. A simplified version of the semantic patch
> used is:
> 
> //<smpl>
> @@
> expression *e;
> @@
> 
> e = devm_kzalloc(...);
> if (e == NULL) {
> ...
> return
> - -1
> + -ENOMEM
> ;
> }
> //</smpl>
> 
> The single call site does not perform any checks on the return value,
> hence no change is required at the call site.
> 
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> ---
>  drivers/platform/goldfish/goldfish_pipe.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
> index e7a29e2..f15e3c9 100644
> --- a/drivers/platform/goldfish/goldfish_pipe.c
> +++ b/drivers/platform/goldfish/goldfish_pipe.c
> @@ -222,7 +222,7 @@ static int setup_access_params_addr(struct platform_device *pdev,
>  
>  	aps = devm_kzalloc(&pdev->dev, sizeof(struct access_params), GFP_KERNEL);
>  	if (!aps)
> -		return -1;
> +		return -ENOMEM;
>  
>  	/* FIXME */
>  	paddr = __pa(aps);

There is another return -1 at the end of the function that should be 
addressed.  Maybe -EINVAL would be an appropriate value, if you don't find 
evidence of anything else.

julia

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] goldfish: Return correct error code Amitoj Kaur Chawla <amitoj1606@gmail.com> - 2016-02-13 15:50 +0100
  Re: [PATCH] goldfish: Return correct error code Julia Lawall <julia.lawall@lip6.fr> - 2016-02-13 20:10 +0100
    Re: [PATCH] goldfish: Return correct error code Amitoj Kaur Chawla <amitoj1606@gmail.com> - 2016-02-14 05:30 +0100

csiph-web