ipc/sem.c: replace kvmalloc/memset with kvzalloc and use struct_size
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Fri, 8 Mar 2019 00:30:26 +0000 (16:30 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 8 Mar 2019 02:32:02 +0000 (18:32 -0800)
commit4a2ae92993be24ba727faa733e99d7980d389ec0
tree14fe968e60afb75c04fa37c4f7ddeb66279d4d17
parent667da6a2688ab061fcd365de677a0ee880fe2bea
ipc/sem.c: replace kvmalloc/memset with kvzalloc and use struct_size

Use kvzalloc() instead of kvmalloc() and memset().

Also, make use of the struct_size() helper instead of the open-coded
version in order to avoid any potential type mistakes.

This code was detected with the help of Coccinelle.

Link: http://lkml.kernel.org/r/20190131214221.GA28930@embeddedor
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Manfred Spraul <manfred@colorfullife.com>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
ipc/sem.c