From: Kevin Traynor <ktraynor@redhat.com>
To: dev@dpdk.org
Cc: maxime.coquelin@redhat.com, Kevin Traynor <ktraynor@redhat.com>,
stable@dpdk.org
Subject: [PATCH 1/1] vhost: add NULL callback checks
Date: Fri, 24 Jan 2025 14:14:07 +0000 [thread overview]
Message-ID: <20250124141408.419674-2-ktraynor@redhat.com> (raw)
In-Reply-To: <20250124141408.419674-1-ktraynor@redhat.com>
rte_vhost_driver_callback_register() does not specify
any mandatory callbacks in struct rte_vhost_device_ops.
Add some missing NULL checks before calling rte_vhost_device_ops
callbacks.
Fixes: 4796ad63ba1f ("examples/vhost: import userspace vhost application")
Cc: stable@dpdk.org
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
---
lib/vhost/vduse.c | 3 ++-
lib/vhost/vhost.c | 5 +++--
lib/vhost/vhost_user.c | 3 ++-
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c
index 8ba58555f9..be548f051e 100644
--- a/lib/vhost/vduse.c
+++ b/lib/vhost/vduse.c
@@ -319,5 +319,6 @@ vduse_device_start(struct virtio_net *dev, bool reconnect)
dev->flags |= VIRTIO_DEV_READY;
- if (dev->notify_ops->new_device(dev->vid) == 0)
+ if (!dev->notify_ops->new_device ||
+ dev->notify_ops->new_device(dev->vid) == 0)
dev->flags |= VIRTIO_DEV_RUNNING;
diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index 5a50a06f8d..c41c29ca57 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -752,8 +752,9 @@ vhost_destroy_device_notify(struct virtio_net *dev)
if (dev->flags & VIRTIO_DEV_RUNNING) {
vdpa_dev = dev->vdpa_dev;
- if (vdpa_dev)
+ if (vdpa_dev && vdpa_dev->ops->dev_close)
vdpa_dev->ops->dev_close(dev->vid);
dev->flags &= ~VIRTIO_DEV_RUNNING;
- dev->notify_ops->destroy_device(dev->vid);
+ if (dev->notify_ops->destroy_device)
+ dev->notify_ops->destroy_device(dev->vid);
}
}
diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 52d8078d7c..26dc0bde97 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -3302,5 +3302,6 @@ vhost_user_msg_handler(int vid, int fd)
if (!(dev->flags & VIRTIO_DEV_RUNNING)) {
- if (dev->notify_ops->new_device(dev->vid) == 0)
+ if (!dev->notify_ops->new_device ||
+ dev->notify_ops->new_device(dev->vid) == 0)
dev->flags |= VIRTIO_DEV_RUNNING;
}
--
2.48.1
prev parent reply other threads:[~2025-01-24 14:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-24 14:14 [PATCH 0/1] vhost: " Kevin Traynor
2025-01-24 14:14 ` Kevin Traynor [this message]
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=20250124141408.419674-2-ktraynor@redhat.com \
--to=ktraynor@redhat.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).