From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 033AE293B for ; Tue, 5 Apr 2016 13:10:57 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP; 05 Apr 2016 04:10:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,443,1455004800"; d="scan'208";a="778372528" Received: from irsmsx107.ger.corp.intel.com ([163.33.3.99]) by orsmga003.jf.intel.com with ESMTP; 05 Apr 2016 04:10:56 -0700 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.19]) by IRSMSX107.ger.corp.intel.com ([169.254.10.137]) with mapi id 14.03.0248.002; Tue, 5 Apr 2016 12:06:56 +0100 From: "Van Haaren, Harry" To: Olivier Matz , "dev@dpdk.org" CC: "Mcnamara, John" Thread-Topic: [dpdk-dev] [PATCH] xstats: fix behavior when a null array is provided Thread-Index: AQHRjokvHieHts8ncEmO3q6P3K/z6J97OPvQ Date: Tue, 5 Apr 2016 11:06:55 +0000 Message-ID: References: <1459784718-22856-1-git-send-email-olivier.matz@6wind.com> In-Reply-To: <1459784718-22856-1-git-send-email-olivier.matz@6wind.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDU5YzEzYmItMjExNS00MjM4LTgwNTItYzliZThmMzkxZTZjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IlJxaXQxQUFOa0FzNUpiTkFxVzhRbk8zZTRWbmQ2amYxMENcL2NIRWQzMFwvND0ifQ== x-ctpclassification: CTP_IC x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] xstats: fix behavior when a null array is provided X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Apr 2016 11:10:58 -0000 > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Olivier Matz > Subject: [dpdk-dev] [PATCH] xstats: fix behavior when a null array is pro= vided >=20 > Coverity reports an issue in ethdev: >=20 > *** CID 124562: Null pointer dereferences (FORWARD_NULL) > /lib/librte_ether/rte_ethdev.c: 1518 in rte_eth_xstats_get() > 1512 > 1513 /* global stats */ > 1514 for (i =3D 0; i < RTE_NB_STATS; i++) { > 1515 stats_ptr =3D RTE_PTR_ADD(ð_stats, > 1516 > rte_stats_strings[i].offset); > 1517 val =3D *stats_ptr; > >>> CID 124562: Null pointer dereferences (FORWARD_NULL) > >>> Dereferencing null pointer "xstats". > 1518 snprintf(xstats[count].name, > sizeof(xstats[count].name), > 1519 "%s", rte_stats_strings[i].name); > 1520 xstats[count++].value =3D val; > 1521 } > 1522 > 1523 /* per-rxq stats */ >=20 > If a user calls rte_eth_xstats_get(portid, NULL, n) with n !=3D 0, > it may result in a crash. Although the API documentation says that > n is the size of the table and xstats can be NULL if n =3D=3D 0, we > can add an additional check here to make Coverity happy. >=20 > In that case, the return value is the same than when n =3D=3D 0 is > passed, it returns the number of statistics. >=20 > Fixes: ce757f5c9a ("ethdev: new method to retrieve extended statistics") > Signed-off-by: Olivier Matz I'm unsure on how verbose commit messages are ideal, but there's certainly enough description here :) Acked-by: Harry van Haaren