mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-17 18:36:00 +00:00
x86/mce/dev-mcelog: Use struct_size() helper in kzalloc()
Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes. This code was detected with the help of Coccinelle and, audited and fixed manually. Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Borislav Petkov <bp@suse.de> Acked-by: Tony Luck <tony.luck@intel.com> Link: https://lkml.kernel.org/r/20200617211734.GA9636@embeddedor
This commit is contained in:
parent
5d7f7d1d5e
commit
5ba7821bcf
@ -345,7 +345,7 @@ static __init int dev_mcelog_init_device(void)
|
||||
int err;
|
||||
|
||||
mce_log_len = max(MCE_LOG_MIN_LEN, num_online_cpus());
|
||||
mcelog = kzalloc(sizeof(*mcelog) + mce_log_len * sizeof(struct mce), GFP_KERNEL);
|
||||
mcelog = kzalloc(struct_size(mcelog, entry, mce_log_len), GFP_KERNEL);
|
||||
if (!mcelog)
|
||||
return -ENOMEM;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user