mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 21:33:52 +00:00
samples: vfio-mdev: fix error handing in mdpy_fb_probe()
[ Upstream commit752774ce77
] 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:cacade1946
("sample: vfio mdev display - guest driver") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Message-Id: <20210520133641.1421378-1-weiyongjun1@huawei.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
870973918b
commit
60dcad10e2
1 changed files with 9 additions and 4 deletions
|
@ -117,22 +117,27 @@ static int mdpy_fb_probe(struct pci_dev *pdev,
|
|||
if (format != DRM_FORMAT_XRGB8888) {
|
||||
pci_err(pdev, "format mismatch (0x%x != 0x%x)\n",
|
||||
format, DRM_FORMAT_XRGB8888);
|
||||
return -EINVAL;
|
||||
ret = -EINVAL;
|
||||
goto err_release_regions;
|
||||
}
|
||||
if (width < 100 || width > 10000) {
|
||||
pci_err(pdev, "width (%d) out of range\n", width);
|
||||
return -EINVAL;
|
||||
ret = -EINVAL;
|
||||
goto err_release_regions;
|
||||
}
|
||||
if (height < 100 || height > 10000) {
|
||||
pci_err(pdev, "height (%d) out of range\n", height);
|
||||
return -EINVAL;
|
||||
ret = -EINVAL;
|
||||
goto err_release_regions;
|
||||
}
|
||||
pci_info(pdev, "mdpy found: %dx%d framebuffer\n",
|
||||
width, height);
|
||||
|
||||
info = framebuffer_alloc(sizeof(struct mdpy_fb_par), &pdev->dev);
|
||||
if (!info)
|
||||
if (!info) {
|
||||
ret = -ENOMEM;
|
||||
goto err_release_regions;
|
||||
}
|
||||
pci_set_drvdata(pdev, info);
|
||||
par = info->par;
|
||||
|
||||
|
|
Loading…
Reference in a new issue