> From: Kozak, KubaX > Sent: Tuesday, May 9, 2017 6:23 AM > To: dev@dpdk.org > Cc: Van Haaren, Harry <harry.van.haa...@intel.com>; Jain, Deepak K > <deepak.k.j...@intel.com>; > Jastrzebski, MichalX K <michalx.k.jastrzeb...@intel.com>; Kozak, KubaX > <kubax.ko...@intel.com> > Subject: [PATCH] proc-info: wrong sizeof argument in malloc function > > From: Michal Jastrzebski <michalx.k.jastrzeb...@intel.com> > > Coverity reported that an argument for sizeof was used improperly. > We should allocate memory for value size that pointer points to, > instead of pointer size itself. > > Coverity issue: 144523, 144521 > Fixes: 7ac16a3660c0 ("app/proc-info: support xstats by ID and by name") > > Signed-off-by: Michal Jastrzebski <michalx.k.jastrzeb...@intel.com>
Please consider merging these in 17.05, this is an important fix for 32 bit systems. Acked-by: Harry van Haaren <harry.van.haa...@intel.com> Details: 64 bit system: sizeof(uint64_t*) == sizeof(uint64_t) 32 bit system: sizeof(uint64_t*) != sizeof(uint64_t) uint64_t *values; > - values = malloc(sizeof(values) * len); > + values = malloc(sizeof(*values) * len); The change here ensures that we allocate sizeof(uint64_t) * len, instead of the incorrect sizeof(void *) * len. Previously on 32 bit systems, only half of the memory required would be allocated.