]> git.baikalelectronics.ru Git - 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)
committerWei Liu <wei.liu@kernel.org>
Thu, 25 Mar 2021 13:31:20 +0000 (13:31 +0000)
commitb3c4c46c9299d7c7c28c86c7acfb9b6cafec7bc2
treed0023f8ac236aa68aa973d30af1b05c3b7492772
parentba0d9f3701f38cf95d1e357af86b1e429730d039
video: hyperv_fb: Fix a double free in hvfb_probe

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: c5c253b04ff7 ("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>
drivers/video/fbdev/hyperv_fb.c