From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by dpdk.org (Postfix) with ESMTP id 11F424D3A for ; Tue, 14 Aug 2018 16:30:54 +0200 (CEST) Received: by mail-wr1-f68.google.com with SMTP id r16-v6so17384392wrt.11 for ; Tue, 14 Aug 2018 07:30:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nAtpUAhVt9PRymbt5xr8vsospfnub2qfL/2BPNoA8cc=; b=m5epH6B0Qx7Eoug3NSX4Mle2vfLM0tsHfLFGRB5Ko9iZie1N4BSQwG/h6qbOHPlj3c WXg6y9vP9XMfl+ICwCNq1PqNRsS9NEDCUDLVJ9nFnpFrw1ihIJe03UqwRLpZ4krEd3kw 2sZGOtfJn4Btqc7bBfVy9apdKFQdGMkvXNunXe0GSl2RUGy1XyAWPPCYWaTs04ZrDO7O MyFE0ZIcWiLiOJdDA0MnTiiqU4QeosabHh+TN3kmMIxakQVUfHJ9Huu2MuRx8Vqbx5GC O77sx/2R+kIkTk5mHV87qJdqz5SMFAazOwi4H7rPqZzaDqXaufkuUwClhtQz4DqS97A+ jn+A== X-Gm-Message-State: AOUpUlEptqpgb+nIKSiI1wmDhIW4Br+YFS80k2ufA6dggH1kjUIz1tMu B7EF/2Df8l/1nj/i+nBT6FQzuz1Q X-Google-Smtp-Source: AA+uWPy/CTqAxtcBCcd9z8MkXHmRoiu+PfIQZaNxiyBV+AnU4qVvFBtzPOlC5aH3hapsSzQXPkXxhw== X-Received: by 2002:a5d:574d:: with SMTP id q13-v6mr12969949wrw.24.1534257053456; Tue, 14 Aug 2018 07:30:53 -0700 (PDT) Received: from localhost ([2001:1be0:110d:fcfe:41aa:5bfa:6cf3:7531]) by smtp.gmail.com with ESMTPSA id j16-v6sm8136186wme.8.2018.08.14.07.30.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Aug 2018 07:30:52 -0700 (PDT) From: Luca Boccassi To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, zhihong.wang@intel.com, tiwei.bie@intel.com, bruce.richardson@intel.com, Brian Russell Date: Tue, 14 Aug 2018 15:30:35 +0100 Message-Id: <20180814143035.19640-2-bluca@debian.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814143035.19640-1-bluca@debian.org> References: <20180814143035.19640-1-bluca@debian.org> Subject: [dpdk-dev] [PATCH 2/2] virtio: fix PCI config err handling X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Aug 2018 14:30:54 -0000 From: Brian Russell In virtio_read_caps, rte_pci_read_config returns the number of bytes read from PCI config or < 0 on error. If less than the expected number of bytes are read then log the failure and return rather than carrying on with garbage. Signed-off-by: Brian Russell --- Follow-up from: http://mails.dpdk.org/archives/dev/2017-June/067278.html https://patches.dpdk.org/patch/25056/ drivers/net/virtio/virtio_pci.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index 6bd22e54a6..a10698aed8 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -567,16 +567,18 @@ virtio_read_caps(struct rte_pci_device *dev, struct virtio_hw *hw) } ret = rte_pci_read_config(dev, &pos, 1, PCI_CAPABILITY_LIST); - if (ret < 0) { - PMD_INIT_LOG(DEBUG, "failed to read pci capability list"); + if (ret != 1) { + PMD_INIT_LOG(DEBUG, + "failed to read pci capability list, ret %d", ret); return -1; } while (pos) { ret = rte_pci_read_config(dev, &cap, sizeof(cap), pos); - if (ret < 0) { - PMD_INIT_LOG(ERR, - "failed to read pci cap at pos: %x", pos); + if (ret != sizeof(cap)) { + PMD_INIT_LOG(DEBUG, + "failed to read pci cap at pos: %x ret %d", + pos, ret); break; } -- 2.18.0