From: Stephen Hemminger <stephen@networkplumber.org>
To: Sunyang Wu <sunyang.wu@jaguarmicro.com>
Cc: dev@dpdk.org, maxime.coquelin@redhat.com, chenbox@nvidia.com
Subject: Re: [PATCH] net/virtio: check return value when calling pthread_mutex_init
Date: Thu, 19 Dec 2024 21:24:12 -0800 [thread overview]
Message-ID: <20241219212412.5782bfec@hermes.local> (raw)
In-Reply-To: <20241220015326.36760-1-sunyang.wu@jaguarmicro.com>
On Fri, 20 Dec 2024 09:53:26 +0800
Sunyang Wu <sunyang.wu@jaguarmicro.com> wrote:
> 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;
This is wasted and dead code.
The man page for pthread_mutex_init explicitly says:
RETURN VALUE
pthread_mutex_init always returns 0.
prev parent reply other threads:[~2024-12-20 5:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-20 1:53 [PATCH] net/virtio: check return value when calling pthread_mutex_init Sunyang Wu
2024-12-20 5:24 ` Stephen Hemminger [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=20241219212412.5782bfec@hermes.local \
--to=stephen@networkplumber.org \
--cc=chenbox@nvidia.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=sunyang.wu@jaguarmicro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.