[PATCH v3] staging: rtl8192u: ieee80211: replace kmalloc/memset with kzalloc

Dan Carpenter dan.carpenter at oracle.com
Mon Oct 26 09:43:33 UTC 2020

On Sun, Oct 25, 2020 at 10:54:31AM -0700, Elena Afanasova wrote:
> Replace kmalloc + memset 0 by a call to kzalloc which zeroes memory too.
> Found with Coccinelle.
> Signed-off-by: Elena Afanasova <eafanasova at gmail.com>
> ---
> Changes in v3:
>         - use array_size()

struct_size() is more correct than array_size().  If there were really
a danger from array overflows then array_size() would not prevent it

There should probably be a static checker warning for when people do
"expr + array_size()".  If you're looking for something to write, that's
an idea you could implement with Coccinelle or Smatch.

dan carpenter

More information about the devel mailing list