Skip to content

Commit 752774c

Browse files
Wei Yongjunawilliam
authored andcommitted
samples: vfio-mdev: fix error handing in mdpy_fb_probe()
Fix to return a negative error code from the framebuffer_alloc() error handling case instead of 0, also release regions in some error handing cases. Fixes: cacade1 ("sample: vfio mdev display - guest driver") Reported-by: Hulk Robot <[email protected]> Signed-off-by: Wei Yongjun <[email protected]> Message-Id: <[email protected]> Signed-off-by: Alex Williamson <[email protected]>
1 parent 78b2381 commit 752774c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

samples/vfio-mdev/mdpy-fb.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,27 @@ static int mdpy_fb_probe(struct pci_dev *pdev,
117117
if (format != DRM_FORMAT_XRGB8888) {
118118
pci_err(pdev, "format mismatch (0x%x != 0x%x)\n",
119119
format, DRM_FORMAT_XRGB8888);
120-
return -EINVAL;
120+
ret = -EINVAL;
121+
goto err_release_regions;
121122
}
122123
if (width < 100 || width > 10000) {
123124
pci_err(pdev, "width (%d) out of range\n", width);
124-
return -EINVAL;
125+
ret = -EINVAL;
126+
goto err_release_regions;
125127
}
126128
if (height < 100 || height > 10000) {
127129
pci_err(pdev, "height (%d) out of range\n", height);
128-
return -EINVAL;
130+
ret = -EINVAL;
131+
goto err_release_regions;
129132
}
130133
pci_info(pdev, "mdpy found: %dx%d framebuffer\n",
131134
width, height);
132135

133136
info = framebuffer_alloc(sizeof(struct mdpy_fb_par), &pdev->dev);
134-
if (!info)
137+
if (!info) {
138+
ret = -ENOMEM;
135139
goto err_release_regions;
140+
}
136141
pci_set_drvdata(pdev, info);
137142
par = info->par;
138143

0 commit comments

Comments
 (0)