From: Julia Lawall <julia.lawall@lip6.fr>
To: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] goldfish: Return correct error code
Date: Sat, 13 Feb 2016 20:02:32 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.02.1602132001340.2068@localhost6.localdomain6> (raw)
In-Reply-To: <20160213144153.GA19589@amitoj-Inspiron-3542>
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
next prev parent reply other threads:[~2016-02-13 19:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-13 14:41 Amitoj Kaur Chawla
2016-02-13 19:02 ` Julia Lawall [this message]
2016-02-14 4:27 ` Amitoj Kaur Chawla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.02.1602132001340.2068@localhost6.localdomain6 \
--to=julia.lawall@lip6.fr \
--cc=amitoj1606@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®