From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 98D0B46128; Fri, 24 Jan 2025 15:14:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 760C542709; Fri, 24 Jan 2025 15:14:49 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 3639042709 for ; Fri, 24 Jan 2025 15:14:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737728086; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n0QNlriuHa0zufzoTapeQm9lK+sRkv0qOSlTH9oU9kM=; b=gfoZ9voNBv9JvVL7L0Nd0M+CnxpI2JVgsgPYTKmAlEe+yqVFibuLcXqJTy0w7mM4qqIjpO 9xCjMfDz7hyRWjZ0lwrwBPecW76GDZWq20fBO210FIPB1s11vZYcz1vk4leNRr3pMQTd3z yKsbDr2QEbjNyBRcRVfNh3STpMrZHfI= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-278-9Lo5C1YRPIOoutBfh7VsRA-1; Fri, 24 Jan 2025 09:14:33 -0500 X-MC-Unique: 9Lo5C1YRPIOoutBfh7VsRA-1 X-Mimecast-MFC-AGG-ID: 9Lo5C1YRPIOoutBfh7VsRA Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3DF721802A9E; Fri, 24 Jan 2025 14:14:28 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 84D681955F1B; Fri, 24 Jan 2025 14:14:26 +0000 (UTC) From: Kevin Traynor To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, Kevin Traynor , stable@dpdk.org Subject: [PATCH 1/1] vhost: add NULL callback checks Date: Fri, 24 Jan 2025 14:14:07 +0000 Message-ID: <20250124141408.419674-2-ktraynor@redhat.com> In-Reply-To: <20250124141408.419674-1-ktraynor@redhat.com> References: <20250124141408.419674-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 8w1XyqSD7kG7D23l9PuzuV3ssF2awvzhTkOE6eo6ViQ_1737728068 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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