Thread (5 messages) 5 messages, 3 authors, 2018-08-27

Re: [PATCH] rtc: sun6i: Use struct_size() in kzalloc()

From: Gustavo A. R. Silva <hidden>
Date: 2018-08-23 22:01:31
Also in: linux-arm-kernel, lkml


On 8/23/18 3:56 PM, Kees Cook wrote:
quoted
-       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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help