Make use of the struct_size() helper instead of an open-coded version, in order to avoid any potential type mistakes or integer overflows that, in the worst scenario, could lead to heap overflows. Signed-off-by: Yu Liao <liaoyu15@xxxxxxxxxx> --- arch/s390/kernel/perf_cpum_cf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_cf.c index 850c11ea631a..e10c7b887f51 100644 --- a/arch/s390/kernel/perf_cpum_cf.c +++ b/arch/s390/kernel/perf_cpum_cf.c @@ -1507,7 +1507,7 @@ static size_t cfset_cpuset_read(struct s390_ctrset_setdata *p, int ctrset, size_t need = 0; int rc = -1; - need = sizeof(*p) + sizeof(u64) * ctrset_size; + need = struct_size(p, cv, ctrset_size); if (need <= room) { p->set = cpumf_ctr_ctl[ctrset]; p->no_cnts = ctrset_size; -- 2.25.1