From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f171.google.com (mail-pf0-f171.google.com [209.85.192.171]) by dpdk.org (Postfix) with ESMTP id E024F594E for ; Tue, 22 Mar 2016 23:09:03 +0100 (CET) Received: by mail-pf0-f171.google.com with SMTP id u190so329369166pfb.3 for ; Tue, 22 Mar 2016 15:09:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=k+Leh83F6MD9Ib8mlWr8mG9zZKs6Cpu/56xnVsHSw5Q=; b=LKOtaUHpCIha+Pyw+otofF/ttlqEV5866H9kpDvbcOCPy7bOnezhhG71ZDFwhpD26o 9ldv64HLDrG6NkmP4T5va4nPwCDCgTr1NM9LvPiY/riOWDQrv9AyTYr5yL/pFp3NUE2X dxdos7rdgnIjUw5PE7sx5gKztX8fjwkJ6PWrsxbtWq4I6zjSE8EZwIBsygm3R+cG7a3q J30DlT3VYXiJZ/WS0SXgmRhra4O6U3hp9BYt6s9869Pa4nrZhPVtogbFdy9odoitF979 E4QifEBtvaiXRRtx1jWAbB/Cu7sHtQ+Bj7B5K5Ca1qrMiMG8DYGxwXR0YGrUKxNrL4a+ E8lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=k+Leh83F6MD9Ib8mlWr8mG9zZKs6Cpu/56xnVsHSw5Q=; b=lD6GCU+JEwK7ZWE4qpdHfyqlQz5BMx7FXabp4i1mQyxtc6p5/Vu25kasV+OWToau/3 kMbAuBr9wqDjwGr4IgQIiwno23jSZ48jy5qIYftfovhROHJcf+P1EB6/e8mB4eHv+An0 OqOqInzXUMYS6EsjL43502Mw0rYG8rb3oPPY0JD+0FqwE+P119zEMjGlrcIEkFHM3xFc Ar3ePJeqKXqLmuB6rC5KO5+xzva01U1keBti0Z9PGCkq41APJ4KgVmzkT7aHdswE7KKh B1cdddOQ/sHtooHn9LXyzbsFgD40oEeSEye2wOmeRBpXHnVnZWkGSfq5U665sICWrPVB Ae9A== X-Gm-Message-State: AD7BkJJs5GLVvaLr8ijZGsH4AVpekKkdUbtLN6S1x/bOYGzMYsvSC5L4znOZrTM09dCWAA== X-Received: by 10.67.3.67 with SMTP id bu3mr57134422pad.39.1458684542922; Tue, 22 Mar 2016 15:09:02 -0700 (PDT) Received: from xeon-e3.home.lan (static-50-53-65-230.bvtn.or.frontiernet.net. [50.53.65.230]) by smtp.gmail.com with ESMTPSA id v9sm50589250pfi.50.2016.03.22.15.09.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Mar 2016 15:09:01 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 22 Mar 2016 15:09:17 -0700 Message-Id: <1458684557-15378-1-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 Subject: [dpdk-dev] [PATCH] ethdev: fix rte_eth_dev_xstats_get with NULL 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, 22 Mar 2016 22:09:04 -0000 Normal usage of rte_eth_dev_xstats_get is to call twice. The first time the function is called with portid, xstats = NULL and n = 0; this returns the number of entries in the statistics table that need to be allocated. The problem is that the routine adds a count value to NULL (0) and assumes that this is a valid pointer (it isn't). Device drivers all have a check for NULL, and this no longer matches. Bug was introduced by commit d4fef8b0d5e5 ("ethdev: expose generic and driver specific stats in xstats") Signed-off-by: Stephen Hemminger --- lib/librte_ether/rte_ethdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index db35102..8721a6b 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1495,8 +1495,9 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, /* Retrieve the xstats from the driver at the end of the * xstats struct. */ - xcount = (*dev->dev_ops->xstats_get)(dev, &xstats[count], - (n > count) ? n - count : 0); + xcount = (*dev->dev_ops->xstats_get)(dev, + xstats ? xstats + count : NULL, + (n > count) ? n - count : 0); if (xcount < 0) return xcount; -- 2.1.4