* [PATCH] goldfish: Return correct error code
@ 2016-02-13 14:41 Amitoj Kaur Chawla
2016-02-13 19:02 ` Julia Lawall
0 siblings, 1 reply; 3+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-13 14:41 UTC (permalink / raw)
To: linux-kernel; +Cc: julia.lawall
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);
--
1.9.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] goldfish: Return correct error code
2016-02-13 14:41 [PATCH] goldfish: Return correct error code Amitoj Kaur Chawla
@ 2016-02-13 19:02 ` Julia Lawall
2016-02-14 4:27 ` Amitoj Kaur Chawla
0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2016-02-13 19:02 UTC (permalink / raw)
To: Amitoj Kaur Chawla; +Cc: linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] goldfish: Return correct error code
2016-02-13 19:02 ` Julia Lawall
@ 2016-02-14 4:27 ` Amitoj Kaur Chawla
0 siblings, 0 replies; 3+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-14 4:27 UTC (permalink / raw)
To: Julia Lawall; +Cc: Linux-Kernel@Vger. Kernel. Org
On Sun, Feb 14, 2016 at 12:32 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> 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
Okay. Will redo and send v2.
Amitoj
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-14 4:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-13 14:41 [PATCH] goldfish: Return correct error code Amitoj Kaur Chawla
2016-02-13 19:02 ` Julia Lawall
2016-02-14 4:27 ` Amitoj Kaur Chawla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®