lkml.org 
[lkml]   [2018]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] rtc: sun6i: Use struct_size() in kzalloc()
From
Date


On 8/23/18 3:56 PM, Kees Cook wrote:

>>
>> - clk_data = kzalloc(sizeof(*clk_data) + (sizeof(*clk_data->hws) * 2),
>> - GFP_KERNEL);
>> + clk_data = kzalloc(struct_size(clk_data, hws, 2), GFP_KERNEL);
>> if (!clk_data) {
>> kfree(rtc);
>> return;
>
> This looks like entirely correct to me, but I'm surprised the
> Coccinelle script didn't discover this. I guess the isomorphisms don't
> cover the parenthesis?
>

Apparently.

If I manually remove the ()s, the cocci script successfully generates a patch.

--
Gustavo

\
 
 \ /
  Last update: 2018-08-24 00:02    [W:0.039 / U:1.844 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site