Skip to content

Commit 2c7d850

Browse files
Yunlongsgregkh
authored andcommitted
video: hyperv_fb: Fix a double free in hvfb_probe
[ Upstream commit 37df9f3 ] Function hvfb_probe() calls hvfb_getmem(), expecting upon return that info->apertures is either NULL or points to memory that should be freed by framebuffer_release(). But hvfb_getmem() is freeing the memory and leaving the pointer non-NULL, resulting in a double free if an error occurs or later if hvfb_remove() is called. Fix this by removing all kfree(info->apertures) calls in hvfb_getmem(). This will allow framebuffer_release() to free the memory, which follows the pattern of other fbdev drivers. Fixes: 3a6fb6c ("video: hyperv: hyperv_fb: Use physical memory for fb on HyperV Gen 1 VMs.") Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Link: https://lore.kernel.org/r/20210324103724.4189-1-lyl2019@mail.ustc.edu.cn Signed-off-by: Wei Liu <wei.liu@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a267a7e commit 2c7d850

1 file changed

Lines changed: 0 additions & 3 deletions

File tree

drivers/video/fbdev/hyperv_fb.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,6 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
10311031
PCI_DEVICE_ID_HYPERV_VIDEO, NULL);
10321032
if (!pdev) {
10331033
pr_err("Unable to find PCI Hyper-V video\n");
1034-
kfree(info->apertures);
10351034
return -ENODEV;
10361035
}
10371036

@@ -1129,7 +1128,6 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
11291128
} else {
11301129
pci_dev_put(pdev);
11311130
}
1132-
kfree(info->apertures);
11331131

11341132
return 0;
11351133

@@ -1141,7 +1139,6 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
11411139
err1:
11421140
if (!gen2vm)
11431141
pci_dev_put(pdev);
1144-
kfree(info->apertures);
11451142

11461143
return -ENOMEM;
11471144
}

0 commit comments

Comments
 (0)