From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <harry.van.haaren@intel.com> Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 99A174A63 for <dev@dpdk.org>; Tue, 9 May 2017 10:44:51 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP; 09 May 2017 01:44:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,313,1491289200"; d="scan'208";a="854623815" Received: from irsmsx101.ger.corp.intel.com ([163.33.3.153]) by FMSMGA003.fm.intel.com with ESMTP; 09 May 2017 01:44:49 -0700 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.153]) by IRSMSX101.ger.corp.intel.com ([163.33.3.153]) with mapi id 14.03.0319.002; Tue, 9 May 2017 09:44:49 +0100 From: "Van Haaren, Harry" <harry.van.haaren@intel.com> To: "dev@dpdk.org" <dev@dpdk.org>, Thomas Monjalon <thomas@monjalon.net> CC: "Jain, Deepak K" <deepak.k.jain@intel.com>, "Jastrzebski, MichalX K" <michalx.k.jastrzebski@intel.com>, "Kozak, KubaX" <kubax.kozak@intel.com> Thread-Topic: [PATCH] proc-info: wrong sizeof argument in malloc function Thread-Index: AQHSyIR+Vd91mHOX60yvsRuDKnoyeqHrrbWw Date: Tue, 9 May 2017 08:44:48 +0000 Message-ID: <E923DB57A917B54B9182A2E928D00FA612A36761@IRSMSX102.ger.corp.intel.com> References: <1494307409-20019-1-git-send-email-kubax.kozak@intel.com> In-Reply-To: <1494307409-20019-1-git-send-email-kubax.kozak@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTIzODk1N2QtZDk3OC00MDQ2LThjOGEtYjMxM2FjMjVmZDQxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkpIQzc2UXdNQmU2NUFnNG9tWG5OM0daeEtjM0NrZW1iTVwvZWhrYWNDd0dzPSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] proc-info: wrong sizeof argument in malloc function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> X-List-Received-Date: Tue, 09 May 2017 08:44:52 -0000 > From: Kozak, KubaX > Sent: Tuesday, May 9, 2017 6:23 AM > To: dev@dpdk.org > Cc: Van Haaren, Harry <harry.van.haaren@intel.com>; Jain, Deepak K <deepa= k.k.jain@intel.com>; > Jastrzebski, MichalX K <michalx.k.jastrzebski@intel.com>; Kozak, KubaX <k= ubax.kozak@intel.com> > Subject: [PATCH] proc-info: wrong sizeof argument in malloc function >=20 > From: Michal Jastrzebski <michalx.k.jastrzebski@intel.com> >=20 > 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. >=20 > Coverity issue: 144523, 144521 > Fixes: 7ac16a3660c0 ("app/proc-info: support xstats by ID and by name") >=20 > Signed-off-by: Michal Jastrzebski <michalx.k.jastrzebski@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.haaren@intel.com> Details: 64 bit system: sizeof(uint64_t*) =3D=3D sizeof(uint64_t) 32 bit system: sizeof(uint64_t*) !=3D sizeof(uint64_t) uint64_t *values; > - values =3D malloc(sizeof(values) * len); > + values =3D 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 all= ocated.