* [PATCH] clk: bcm/kona: Do not use sizeof on pointer type
@ 2016-04-28 13:50 Vaishali Thakkar
2016-05-06 18:06 ` Stephen Boyd
0 siblings, 1 reply; 2+ messages in thread
From: Vaishali Thakkar @ 2016-04-28 13:50 UTC (permalink / raw)
To: mturquette; +Cc: linux-clk, linux-kernel, sboyd, Vaishali Thakkar
When sizeof is applied to a pointer typed expression, it gives
the size of the pointer. So, here do not use sizeof on pointer
type. Also, silent checkpatch.pl by using kmalloc_array over
kmalloc.
Note that this has no effect on runtime because 'parent_names'
is a pointer to a pointer.
Problem found using Coccinelle.
Signed-off-by: Vaishali Thakkar <vaishali.thakkar@oracle.com>
---
drivers/clk/bcm/clk-kona-setup.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/bcm/clk-kona-setup.c b/drivers/clk/bcm/clk-kona-setup.c
index deaa7f9..526b0b0 100644
--- a/drivers/clk/bcm/clk-kona-setup.c
+++ b/drivers/clk/bcm/clk-kona-setup.c
@@ -577,7 +577,8 @@ static u32 *parent_process(const char *clocks[],
* selector is not required, but we allocate space for the
* array anyway to keep things simple.
*/
- parent_names = kmalloc(parent_count * sizeof(parent_names), GFP_KERNEL);
+ parent_names = kmalloc_array(parent_count, sizeof(*parent_names),
+ GFP_KERNEL);
if (!parent_names) {
pr_err("%s: error allocating %u parent names\n", __func__,
parent_count);
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] clk: bcm/kona: Do not use sizeof on pointer type
2016-04-28 13:50 [PATCH] clk: bcm/kona: Do not use sizeof on pointer type Vaishali Thakkar
@ 2016-05-06 18:06 ` Stephen Boyd
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2016-05-06 18:06 UTC (permalink / raw)
To: Vaishali Thakkar; +Cc: mturquette, linux-clk, linux-kernel
On 04/28, Vaishali Thakkar wrote:
> When sizeof is applied to a pointer typed expression, it gives
> the size of the pointer. So, here do not use sizeof on pointer
> type. Also, silent checkpatch.pl by using kmalloc_array over
> kmalloc.
>
> Note that this has no effect on runtime because 'parent_names'
> is a pointer to a pointer.
>
> Problem found using Coccinelle.
>
> Signed-off-by: Vaishali Thakkar <vaishali.thakkar@oracle.com>
> ---
Applied to clk-next
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-05-06 18:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-28 13:50 [PATCH] clk: bcm/kona: Do not use sizeof on pointer type Vaishali Thakkar
2016-05-06 18:06 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox