* [PATCH -next] tee: optee: fix type warning of sizeof in pool_op_alloc()
@ 2020-09-17 8:13 Liu Shixin
2020-09-24 7:33 ` Jens Wiklander
0 siblings, 1 reply; 2+ messages in thread
From: Liu Shixin @ 2020-09-17 8:13 UTC (permalink / raw)
To: Jens Wiklander; +Cc: op-tee, linux-kernel, Liu Shixin
sizeof() when applied to a pointer typed expression should gives the
size of the pointed data, even if the data is a pointer.
Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
drivers/tee/optee/shm_pool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tee/optee/shm_pool.c b/drivers/tee/optee/shm_pool.c
index d767eebf30bd..9fdc667b5df0 100644
--- a/drivers/tee/optee/shm_pool.c
+++ b/drivers/tee/optee/shm_pool.c
@@ -31,7 +31,7 @@ static int pool_op_alloc(struct tee_shm_pool_mgr *poolm,
unsigned int nr_pages = 1 << order, i;
struct page **pages;
- pages = kcalloc(nr_pages, sizeof(pages), GFP_KERNEL);
+ pages = kcalloc(nr_pages, sizeof(*pages), GFP_KERNEL);
if (!pages)
return -ENOMEM;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] tee: optee: fix type warning of sizeof in pool_op_alloc()
2020-09-17 8:13 [PATCH -next] tee: optee: fix type warning of sizeof in pool_op_alloc() Liu Shixin
@ 2020-09-24 7:33 ` Jens Wiklander
0 siblings, 0 replies; 2+ messages in thread
From: Jens Wiklander @ 2020-09-24 7:33 UTC (permalink / raw)
To: Liu Shixin; +Cc: op-tee, Linux Kernel Mailing List
On Thu, Sep 17, 2020 at 9:52 AM Liu Shixin <liushixin2@huawei.com> wrote:
>
> sizeof() when applied to a pointer typed expression should gives the
> size of the pointed data, even if the data is a pointer.
>
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
> ---
> drivers/tee/optee/shm_pool.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tee/optee/shm_pool.c b/drivers/tee/optee/shm_pool.c
> index d767eebf30bd..9fdc667b5df0 100644
> --- a/drivers/tee/optee/shm_pool.c
> +++ b/drivers/tee/optee/shm_pool.c
> @@ -31,7 +31,7 @@ static int pool_op_alloc(struct tee_shm_pool_mgr *poolm,
> unsigned int nr_pages = 1 << order, i;
> struct page **pages;
>
> - pages = kcalloc(nr_pages, sizeof(pages), GFP_KERNEL);
> + pages = kcalloc(nr_pages, sizeof(*pages), GFP_KERNEL);
In this case we want an array of pointers as you also can see in the
type of "pages".
Thanks,
Jens
> if (!pages)
> return -ENOMEM;
>
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-24 7:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 8:13 [PATCH -next] tee: optee: fix type warning of sizeof in pool_op_alloc() Liu Shixin
2020-09-24 7:33 ` Jens Wiklander
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).