]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
video: hyperv_fb: Fix a double free in hvfb_probe
authorLv Yunlong <lyl2019@mail.ustc.edu.cn>
Wed, 24 Mar 2021 10:37:24 +0000 (03:37 -0700)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 8 Apr 2021 20:42:52 +0000 (15:42 -0500)
commitff670751e9cd23fc75873ffbdcae84e96c958406
treeabd2f4fead2835d1c9240c8d7434ba6c5a5482fd
parent33666516e74b471865d7f37834eba321dfe31f1c
video: hyperv_fb: Fix a double free in hvfb_probe

BugLink: https://bugs.launchpad.net/bugs/1923069
[ Upstream commit 37df9f3fedb6aeaff5564145e8162aab912c9284 ]

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: 3a6fb6c4255c ("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>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
drivers/video/fbdev/hyperv_fb.c