Skip to content

Commit 2b847f2

Browse files
YongjiXiemstsirkin
authored andcommitted
vdpa_sim: Fix return value check for vdpa_alloc_device()
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: 2c53d0f ("vdpasim: vDPA device simulator") Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Xie Yongji <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]>
1 parent f7ad318 commit 2b847f2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/vdpa/vdpa_sim/vdpa_sim.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,10 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr)
251251

252252
vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops,
253253
dev_attr->name);
254-
if (!vdpasim)
254+
if (IS_ERR(vdpasim)) {
255+
ret = PTR_ERR(vdpasim);
255256
goto err_alloc;
257+
}
256258

257259
vdpasim->dev_attr = *dev_attr;
258260
INIT_WORK(&vdpasim->work, dev_attr->work_fn);

0 commit comments

Comments
 (0)