[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210824165607.709387-44-sashal@kernel.org>
Date: Tue, 24 Aug 2021 12:54:43 -0400
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: Xie Yongji <xieyongji@...edance.com>,
Dan Carpenter <dan.carpenter@...cle.com>,
"Michael S . Tsirkin" <mst@...hat.com>,
Stefano Garzarella <sgarzare@...hat.com>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH 5.13 043/127] vdpa_sim: Fix return value check for vdpa_alloc_device()
From: Xie Yongji <xieyongji@...edance.com>
[ Upstream commit 2b847f21145d84e2e1dde99d3e2c00a5468f02e4 ]
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@...cle.com>
Signed-off-by: Xie Yongji <xieyongji@...edance.com>
Link: https://lore.kernel.org/r/20210715080026.242-1-xieyongji@bytedance.com
Signed-off-by: Michael S. Tsirkin <mst@...hat.com>
Reviewed-by: Stefano Garzarella <sgarzare@...hat.com>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
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 98f793bc9376..26337ba42445 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.30.2
Powered by blists - more mailing lists