From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com [209.85.215.53]) by dpdk.org (Postfix) with ESMTP id BC9C81B6AD for ; Mon, 16 Oct 2017 13:46:00 +0200 (CEST) Received: by mail-lf0-f53.google.com with SMTP id a132so16627874lfa.7 for ; Mon, 16 Oct 2017 04:46:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PlGZUgfU9GEC8E1nlHQLBKQ4cLJRpL6TK4Vetn+9Rkc=; b=owg76yHUGG5kB+1A4qsGJp6d7w9MUOKuyMn9F9iuNYGwNF5BewKDpgbmYeWHVdwJyS ec09ujnHEGoT6MOijZkSeT7uyB3UzYGxVjmLGnEsZVTRyrV5G5Slt7KbEcAtCJU62Oaq aAGxhBbcPp0zdb3DPyqiTsqVkRF+UyV2aihh3FNIlYwDjGvuw/I8vs1ejL7mYtlN5RPZ 88O/v9dQfR90slxqHlz71JbNfd4q4X0kgYZ3ShLndPWHlYcsMiuWGA1ypFIuMpVYrs3J sLuZ4YHfeSFzOoEEotExLtJwuAugUMBfLKPKMGK/T1ax5UVhkIczVIRTk4vKy5+VmzOQ 4hnw== 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=PlGZUgfU9GEC8E1nlHQLBKQ4cLJRpL6TK4Vetn+9Rkc=; b=BQJIQH68di9dcH+G2PbOJDUHZ7g6OBnJ1ocleo/HXJQil3M5TaR4tkSecn1WjXQjhd mQgFP7IAxZMRtWZK2J25KTOHvnrk0y0ZUzA26zV2sESVnD8sWxbtjG4DVZ6C79Gt0dRN iVTtWf1ZUKubWSR9NFnUVyz5yjGI/lDws57YDUdNMadVtFNvttCsunEfNspIfrjlFUr+ Fvw1z1Z+NSd7kVhsWWv380jxD8QGsX2Q+L0l7+nAEcrtrUyCkdItuizW42n3Zg15qaj/ ynQC8zRTwKWSoKq8mAzLZ1aq4/81FkO5lr20x4dbfkTcgC1+EhGnpHpaThUusvsw8Om1 RoXQ== X-Gm-Message-State: AMCzsaUFf+Hp0slhlkKyud+ZatqgI0TRb4qVVyeitQXjfNSOZz+bptff SHzkplSNi7UZsQaVpsg7uc7odYDJcE0= X-Google-Smtp-Source: ABhQp+Scj4r0XtTxTI1hGJ4G+UNpvh686AjbcE31iiFa7umLQk2JsxEHqxXWonSDdRa6ZklELQ98zQ== X-Received: by 10.25.28.148 with SMTP id c142mr3301872lfc.34.1508154360084; Mon, 16 Oct 2017 04:46:00 -0700 (PDT) Received: from tdu.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id c23sm1469607lfh.65.2017.10.16.04.45.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Oct 2017 04:45:59 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: Tomasz Duszynski Date: Mon, 16 Oct 2017 13:45:47 +0200 Message-Id: <1508154348-10988-2-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508154348-10988-1-git-send-email-tdu@semihalf.com> References: <1508154348-10988-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH 1/2] examples/kni: check if pci_dev isn't NULL before using it 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: Mon, 16 Oct 2017 11:46:00 -0000 Since virtual devices, i.e mrvl net pmd, do not touch pci_dev dereferencing it will cause segmentation fault as by default it's set to NULL in rte_eth_dev_info_get(). Signed-off-by: Tomasz Duszynski --- examples/kni/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/kni/main.c b/examples/kni/main.c index 6d9e4a6..cb48fb5 100644 --- a/examples/kni/main.c +++ b/examples/kni/main.c @@ -805,8 +805,11 @@ kni_alloc(uint16_t port_id) memset(&dev_info, 0, sizeof(dev_info)); rte_eth_dev_info_get(port_id, &dev_info); - conf.addr = dev_info.pci_dev->addr; - conf.id = dev_info.pci_dev->id; + + if (dev_info.pci_dev) { + conf.addr = dev_info.pci_dev->addr; + conf.id = dev_info.pci_dev->id; + } memset(&ops, 0, sizeof(ops)); ops.port_id = port_id; -- 2.7.4