From: Alexander Chernavin <achernavin@netgate.com>
To: maxime.coquelin@redhat.com, chenbo.xia@intel.com
Cc: dev@dpdk.org, Alexander Chernavin <achernavin@netgate.com>,
stable@dpdk.org
Subject: [PATCH v2] net/virtio: fix crash when dev is configured twice
Date: Mon, 26 Sep 2022 08:32:12 +0000 [thread overview]
Message-ID: <20220926083212.1178663-1-achernavin@netgate.com> (raw)
In-Reply-To: <20220831085344.47995-1-achernavin@netgate.com>
When first attempt to configure a device with RX interrupt enabled fails
for some reason (e.g. because "Multiple intr vector not supported"),
second attempt to configure the device with RX interrupt disabled and
feature set unchanged will succeed but will leave virtio queues not
allocated. Accessing the queues will cause a segfault.
First attempt:
- virtio_dev_configure()
- virtio_init_device() is called to reinit the device because
"dev->data->dev_conf.intr_conf.rxq" is "1"
- virtio_configure_intr() fails and returns an error
- virtio_free_queues() frees previously allocated virtio queues
- virtio_init_device() fails and returns an error
- virtio_dev_configure() fails and returns an error
Second attempt:
- virtio_dev_configure()
- This time virtio_init_device() is not called, virtio queues
are not allocated
With this fix, reinit the device during configuration if virtio queues
are not allocated.
Cc: stable@dpdk.org
Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
---
v2:
* Also CC to stable@dpdk.org
drivers/net/virtio/virtio_ethdev.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index d180162abd..38bfe050b5 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -2616,6 +2616,13 @@ virtio_dev_configure(struct rte_eth_dev *dev)
return ret;
}
+ /* if queues are not allocated, reinit the device */
+ if (hw->vqs == NULL) {
+ ret = virtio_init_device(dev, hw->req_guest_features);
+ if (ret < 0)
+ return ret;
+ }
+
if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) &&
!virtio_with_feature(hw, VIRTIO_NET_F_RSS)) {
PMD_DRV_LOG(ERR, "RSS support requested but not supported by the device");
--
2.25.1
next parent reply other threads:[~2022-09-26 8:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220831085344.47995-1-achernavin@netgate.com>
2022-09-26 8:32 ` Alexander Chernavin [this message]
2022-09-27 10:15 ` [PATCH v3] " Alexander Chernavin
2022-09-28 4:47 ` Xia, Chenbo
2022-09-29 8:33 ` Xia, Chenbo
2022-09-26 8:23 [PATCH v2] " Alexander Chernavin
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=20220926083212.1178663-1-achernavin@netgate.com \
--to=achernavin@netgate.com \
--cc=chenbo.xia@intel.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=stable@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).