From: Sunyang Wu <sunyang.wu@jaguarmicro.com>
To: dev@dpdk.org
Cc: maxime.coquelin@redhat.com, chenbox@nvidia.com
Subject: [PATCH] net/virtio: check return value when calling pthread_mutex_init
Date: Fri, 20 Dec 2024 09:53:26 +0800 [thread overview]
Message-ID: <20241220015326.36760-1-sunyang.wu@jaguarmicro.com> (raw)
Add validation for the return value of the pthread_mutex_init.
Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>
---
drivers/net/virtio/virtio_user/virtio_user_dev.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 2997d2bd26..00272cf802 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -735,8 +735,13 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,
enum virtio_user_backend_type backend_type)
{
uint64_t backend_features;
+ int ret;
- pthread_mutex_init(&dev->mutex, NULL);
+ ret = pthread_mutex_init(&dev->mutex, NULL);
+ if (ret) {
+ PMD_INIT_LOG(ERR, "(%s) init dev mutex failed", dev->path);
+ return ret;
+ }
strlcpy(dev->path, path, PATH_MAX);
dev->started = 0;
--
2.19.0.rc0.windows.1
next reply other threads:[~2024-12-20 1:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-20 1:53 Sunyang Wu [this message]
2024-12-20 5:24 ` Stephen Hemminger
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=20241220015326.36760-1-sunyang.wu@jaguarmicro.com \
--to=sunyang.wu@jaguarmicro.com \
--cc=chenbox@nvidia.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
/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).