summaryrefslogtreecommitdiffstats
path: root/drivers/clk/x86/clk-st.c
diff options
context:
space:
mode:
authorGustavo A. R. Silva2018-08-24 01:06:54 +0200
committerStephen Boyd2018-08-29 00:12:59 +0200
commit450b6b9b169382205f88858541a8b79830262ce7 (patch)
treebd9fc3f1b4ffae47e80d37dbf8f4c054850ceca0 /drivers/clk/x86/clk-st.c
parentLinux 4.19-rc1 (diff)
downloadkernel-qcow2-linux-450b6b9b169382205f88858541a8b79830262ce7.tar.gz
kernel-qcow2-linux-450b6b9b169382205f88858541a8b79830262ce7.tar.xz
kernel-qcow2-linux-450b6b9b169382205f88858541a8b79830262ce7.zip
clk: npcm7xx: fix memory allocation
One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. For example: struct foo { int stuff; void *entry[]; }; instance = kzalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL); Instead of leaving these open-coded and prone to type mistakes, we can now use the new struct_size() helper: instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL); Notice that, currently, there is a bug during the allocation: sizeof(npcm7xx_clk_data) should be sizeof(*npcm7xx_clk_data) Fix this bug by using struct_size() in kzalloc() This issue was detected with the help of Coccinelle. Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Avi Fishman <avifishman70@gmail.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/clk/x86/clk-st.c')
0 files changed, 0 insertions, 0 deletions