All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xie Yongji <xieyongji@bytedance.com>
To: mst@redhat.com, jasowang@redhat.com, dan.carpenter@oracle.com
Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/4] vdpa_sim: Fix return value check for vdpa_alloc_device()
Date: Thu, 15 Jul 2021 16:00:23 +0800	[thread overview]
Message-ID: <20210715080026.242-1-xieyongji@bytedance.com> (raw)

The vdpa_alloc_device() returns an error pointer upon
failure, not NULL. To handle the failure correctly, this
replaces NULL check with IS_ERR() check and propagate the
error upwards.

Fixes: 2c53d0f64c06 ("vdpasim: vDPA device simulator")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
---
 drivers/vdpa/vdpa_sim/vdpa_sim.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index 14e024de5cbf..c621cf7feec0 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -251,8 +251,10 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr)
 
 	vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops,
 				    dev_attr->name);
-	if (!vdpasim)
+	if (IS_ERR(vdpasim)) {
+		ret = PTR_ERR(vdpasim);
 		goto err_alloc;
+	}
 
 	vdpasim->dev_attr = *dev_attr;
 	INIT_WORK(&vdpasim->work, dev_attr->work_fn);
-- 
2.11.0


             reply	other threads:[~2021-07-15  8:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15  8:00 Xie Yongji [this message]
2021-07-15  8:00 ` [PATCH 2/4] vp_vdpa: Fix return value check for vdpa_alloc_device() Xie Yongji
2021-07-15  8:08   ` Jason Wang
2021-07-15  8:08     ` Jason Wang
2021-07-26  9:28   ` Stefano Garzarella
2021-07-26  9:28     ` Stefano Garzarella
2021-07-15  8:00 ` [PATCH 3/4] vDPA/ifcvf: " Xie Yongji
2021-07-15  8:09   ` Jason Wang
2021-07-15  8:09     ` Jason Wang
2021-07-26  9:28   ` Stefano Garzarella
2021-07-26  9:28     ` Stefano Garzarella
2021-07-15  8:00 ` [PATCH 4/4] vdpa: Add documentation for vdpa_alloc_device() macro Xie Yongji
2021-07-15  8:10   ` Jason Wang
2021-07-15  8:10     ` Jason Wang
2021-07-26  9:29   ` Stefano Garzarella
2021-07-26  9:29     ` Stefano Garzarella
2021-07-26  9:28 ` [PATCH 1/4] vdpa_sim: Fix return value check for vdpa_alloc_device() Stefano Garzarella
2021-07-26  9:28   ` Stefano Garzarella
  -- strict thread matches above, loose matches on Subject: below --
2021-07-15  7:59 Xie Yongji
2021-07-15  8:03 ` Jason Wang
2021-07-15  8:03   ` Jason Wang

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=20210715080026.242-1-xieyongji@bytedance.com \
    --to=xieyongji@bytedance.com \
    --cc=dan.carpenter@oracle.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.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 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.