From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: sayli karnik <karniksayli1995@gmail.com>
Cc: outreachy-kernel@googlegroups.com,
"Laura Abbott" <labbott@redhat.com>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Arve Hjønnevåg" <arve@android.com>,
"Riley Andrews" <riandrews@android.com>
Subject: Re: [PATCH] staging: android: ion: hisilicon: Use pointer to memory being allocated as the sizeof argument
Date: Wed, 21 Sep 2016 18:15:46 +0200 [thread overview]
Message-ID: <20160921161546.GA28028@kroah.com> (raw)
In-Reply-To: <20160921154114.GA18681@sayli-HP-15-Notebook-PC>
On Wed, Sep 21, 2016 at 09:11:14PM +0530, sayli karnik wrote:
> This patch finds cases where the argument to sizeof is wrong in memory
> allocation functions by checking the type of the allocated memory when it is a
> double pointer and ensuring the sizeof argument takes a pointer to the memory
> being allocated.
Are you sure?
> Done using coccinelle:
> @@
> type T;
> T **x;
> @@
>
> x =
> <+...sizeof(
> - T
> + *x
> )...+>
>
> Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
> ---
> drivers/staging/android/ion/hisilicon/hi6220_ion.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/android/ion/hisilicon/hi6220_ion.c b/drivers/staging/android/ion/hisilicon/hi6220_ion.c
> index 659aa71..9f9b244 100644
> --- a/drivers/staging/android/ion/hisilicon/hi6220_ion.c
> +++ b/drivers/staging/android/ion/hisilicon/hi6220_ion.c
> @@ -57,7 +57,7 @@ static int hi6220_ion_probe(struct platform_device *pdev)
> return PTR_ERR(ipdev->data);
>
> ipdev->heaps = devm_kzalloc(&pdev->dev,
> - sizeof(struct ion_heap)*ipdev->data->nr,
> + sizeof(*ipdev->heaps) * ipdev->data->nr,
Do we really want to allocate an array of pointers, or an array of
structures? Which is it, as it's not obvious...
thanks,
greg k-h
next prev parent reply other threads:[~2016-09-21 16:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-21 15:41 [PATCH] staging: android: ion: hisilicon: Use pointer to memory being allocated as the sizeof argument sayli karnik
2016-09-21 16:15 ` Greg Kroah-Hartman [this message]
2016-09-21 16:31 ` sayli karnik
2016-09-21 16:36 ` [Outreachy kernel] " Julia Lawall
2016-09-21 16:41 ` Greg Kroah-Hartman
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=20160921161546.GA28028@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=arve@android.com \
--cc=karniksayli1995@gmail.com \
--cc=labbott@redhat.com \
--cc=outreachy-kernel@googlegroups.com \
--cc=riandrews@android.com \
--cc=sumit.semwal@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.