From: Tomasz Duszynski <tdu@semihalf.com>
To: dev@dpdk.org
Cc: Tomasz Duszynski <tdu@semihalf.com>
Subject: [dpdk-dev] [PATCH 1/2] examples/kni: check if pci_dev isn't NULL before using it
Date: Mon, 16 Oct 2017 13:45:47 +0200 [thread overview]
Message-ID: <1508154348-10988-2-git-send-email-tdu@semihalf.com> (raw)
In-Reply-To: <1508154348-10988-1-git-send-email-tdu@semihalf.com>
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 <tdu@semihalf.com>
---
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
next prev parent reply other threads:[~2017-10-16 11:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-16 11:45 [dpdk-dev] [PATCH 0/2] examples/kni: update kni example application Tomasz Duszynski
2017-10-16 11:45 ` Tomasz Duszynski [this message]
2017-10-21 0:26 ` [dpdk-dev] [PATCH 1/2] examples/kni: check if pci_dev isn't NULL before using it Ferruh Yigit
2017-10-24 22:05 ` Thomas Monjalon
2017-10-16 11:45 ` [dpdk-dev] [PATCH 2/2] examples/kni: stop lcores while doing kni ops Tomasz Duszynski
2017-10-21 0:42 ` Ferruh Yigit
2017-10-25 9:28 ` Tomasz Duszynski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1508154348-10988-2-git-send-email-tdu@semihalf.com \
--to=tdu@semihalf.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).