In function hvfb_probe in hyperv_fb.c, it calls hvfb_getmem(hdev, info)
and return err when info->apertures is freed.
In the error1 label of hvfb_probe, info->apertures will be freed twice
by framebuffer_release(info).
My patch sets info->apertures to NULL after it was freed to avoid
double free.
Signed-off-by: Lv Yunlong <redacted>
---
drivers/video/fbdev/hyperv_fb.c | 3 +++
1 file changed, 3 insertions(+)
From: Wei Liu <wei.liu@kernel.org> Date: 2021-03-23 11:29:46
Thanks for your patch.
I would like to change the prefix to "video: hyperv_fb:" to be more
specific.
On Tue, Mar 23, 2021 at 12:33:50AM -0700, Lv Yunlong wrote:
In function hvfb_probe in hyperv_fb.c, it calls hvfb_getmem(hdev, info)
and return err when info->apertures is freed.
In the error1 label of hvfb_probe, info->apertures will be freed twice
by framebuffer_release(info).
I would say "freed for the second time" here. What you wrote reads to me
fraembuffer_release frees the buffer twice all by itself.
My patch sets info->apertures to NULL after it was freed to avoid
double free.
I think this approach works. I would like to give other people a chance
to comment though.
Fixes: 3a6fb6c4255c ("video: hyperv: hyperv_fb: Use physical memory for fb on HyperV Gen 1 VMs.")
From: Michael Kelley <hidden> Date: 2021-03-23 18:52:45
From: Lv Yunlong <redacted> Sent: Tuesday, March 23, 2021 12:34 AM
quoted hunk
In function hvfb_probe in hyperv_fb.c, it calls hvfb_getmem(hdev, info)
and return err when info->apertures is freed.
In the error1 label of hvfb_probe, info->apertures will be freed twice
by framebuffer_release(info).
My patch sets info->apertures to NULL after it was freed to avoid
double free.
Signed-off-by: Lv Yunlong <redacted>
---
drivers/video/fbdev/hyperv_fb.c | 3 +++
1 file changed, 3 insertions(+)
While I think this works, a slightly better solution might be to remove
all calls to kfree(info->apertures) in hvfb_getmem(), and just let
framebuffer_release() handle freeing the memory. That's what is
done in other drivers that follow the fbdev pattern, and it's less
code overall.
Michael
In function hvfb_probe in hyperv_fb.c, it calls hvfb_getmem(hdev, info)
and return err when info->apertures is freed.
In the error1 label of hvfb_probe, info->apertures will be freed twice
by framebuffer_release(info).
My patch sets info->apertures to NULL after it was freed to avoid
double free.
Signed-off-by: Lv Yunlong <redacted>
---
drivers/video/fbdev/hyperv_fb.c | 3 +++
1 file changed, 3 insertions(+)
While I think this works, a slightly better solution might be to remove
all calls to kfree(info->apertures) in hvfb_getmem(), and just let
framebuffer_release() handle freeing the memory. That's what is
done in other drivers that follow the fbdev pattern, and it's less
code overall.
Michael
Ok, i agree with you. Remove all calls to kfree(info->apertures)
in hvfb_getmem() is a better solution.
I will subimt a PATCH v2 for you to review. Thanks.