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 C80D645EF4; Fri, 20 Dec 2024 06:24:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6183640267; Fri, 20 Dec 2024 06:24:16 +0100 (CET) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by mails.dpdk.org (Postfix) with ESMTP id 1FAED40144 for ; Fri, 20 Dec 2024 06:24:15 +0100 (CET) Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2166651f752so15964155ad.3 for ; Thu, 19 Dec 2024 21:24:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1734672254; x=1735277054; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=lKXpFYY/Xh7jRH/jG8T0sAFWwB84U1pDrkczt/gLM68=; b=kVxUYZmHKhWzxdqKt30RBnqWfZsEdQiyTacOyQtSmJA+r1kslQ/+auje6OxJeO649J qArmvVHsejx0Ayve2+PMGfz1FlnR3rs1HU+amLXMTxr+Z7gj6yIS8M4HI4fbNNg/bvrf 7vNp4Q1EXqUS1r2sGemjkMfAuVJ++nuaVAZOTRlaIEnCHOgQCDGNX+ztFRO6oxDy+g3v +3aCiGn5P7qEyKF9NAL9Dv4I6vSpfiuRYlbpsW1Rs16W3/6u/qkbC+bmM0zM93ssvT0x uNmrkvA1kafrYdjDErHM2KPOMFSeGmHWcKovWK1QIZUMxgiDZBYVIHeZeAzZsLKxk/oJ h/0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734672254; x=1735277054; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lKXpFYY/Xh7jRH/jG8T0sAFWwB84U1pDrkczt/gLM68=; b=OyhSEIruvO2gymj1wtKQtMAz3NwvrKUqvxVVn0I0HiXrfkbjiTuztrQ5bdRONaqGw2 ACEChdBlXnYGpz6aYWB/ilQIk6HyPJMhST9SXh7viCT/BKHv+VQc0KAOhbxS4fIfwx4G ov0Ap69OBm/ikqUvB/wDRvNEoKOBAxC/9qBtSJN3UIZxl7RiBk2xdAjqztHJ5USWMTTE AafYr00jY836zMCgoloPlVmXtGdfL7efZhS7lLBvoHo3XSEwU1Rydr3xR8dovMswPGhb rq2RPgB8U8/r1Do96MQGMSVchsPWtqmjY11+7qmVgirek7urB5rmexQHBaizakLmJ5Go nUOA== X-Gm-Message-State: AOJu0Yxn7G/u16GOw2h6Mhk3OAsVkIol/aKdEKBgbbF+4IpuZWyjJCQa KPUtHkX61e41HQwgwQN0CuFbhy/cYzifZg2oNekE/VD57FNNZO8ANCzsgPk/zwQ= X-Gm-Gg: ASbGncuvLGTY+TExw+TTG6PRQe+wIec5J/Tk5Ys3SSejg9GZlBGn4caQMp5w/iI1zSR xU+DvILs4I3Kx9Gyl+zHnTqvYD2Q3TvTV4G40ceSJDCW0k9S/xFHagCj4z/A2vLwaPVY9xT7vHm H4KcsSllS53fMqbH15/haGNeh0QzFGF3UJFEdwYt3MuQMGUIQScQwlfhfh1ftdbPFTRQMYM+B+H hCHgvFEYHhF2wc1bk1Qy08o42JQSYPWgmmAxt9AKWme4XJeRbxSrmyHoYcVkGNsSLKucXIgET/y vTaaIHQVa2pT3hYgYLoYv3AJa5zhWAg05Q== X-Google-Smtp-Source: AGHT+IGwg4PENrAFnNL7i9Ri3iYJwMrQEBtvTQqbh/6/VnM43n46YLCEYaTlNcTwl/QwvYK59nY85w== X-Received: by 2002:a17:902:e883:b0:216:48f4:4f20 with SMTP id d9443c01a7336-219e6e9fb14mr21976875ad.16.1734672254346; Thu, 19 Dec 2024 21:24:14 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9f6922sm21154735ad.223.2024.12.19.21.24.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 21:24:14 -0800 (PST) Date: Thu, 19 Dec 2024 21:24:12 -0800 From: Stephen Hemminger To: Sunyang Wu Cc: dev@dpdk.org, maxime.coquelin@redhat.com, chenbox@nvidia.com Subject: Re: [PATCH] net/virtio: check return value when calling pthread_mutex_init Message-ID: <20241219212412.5782bfec@hermes.local> In-Reply-To: <20241220015326.36760-1-sunyang.wu@jaguarmicro.com> References: <20241220015326.36760-1-sunyang.wu@jaguarmicro.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Fri, 20 Dec 2024 09:53:26 +0800 Sunyang Wu wrote: > Add validation for the return value of the pthread_mutex_init. > > Signed-off-by: Sunyang Wu > --- > 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.