From: Lv Yunlong <lyl2019@mail.ustc.edu.cn> To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org Cc: linux-hyperv@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lv Yunlong <lyl2019@mail.ustc.edu.cn> Subject: [PATCH] video/fbdev: Fix a double free in hvfb_probe Date: Tue, 23 Mar 2021 00:33:50 -0700 [thread overview] Message-ID: <20210323073350.17697-1-lyl2019@mail.ustc.edu.cn> (raw) 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 <lyl2019@mail.ustc.edu.cn> --- drivers/video/fbdev/hyperv_fb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c index c8b0ae676809..2fc9b507e73a 100644 --- a/drivers/video/fbdev/hyperv_fb.c +++ b/drivers/video/fbdev/hyperv_fb.c @@ -1032,6 +1032,7 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info) if (!pdev) { pr_err("Unable to find PCI Hyper-V video\n"); kfree(info->apertures); + info->apertures = NULL; return -ENODEV; } @@ -1130,6 +1131,7 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info) pci_dev_put(pdev); } kfree(info->apertures); + info->apertures = NULL; return 0; @@ -1142,6 +1144,7 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info) if (!gen2vm) pci_dev_put(pdev); kfree(info->apertures); + info->apertures = NULL; return -ENOMEM; } -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Lv Yunlong <lyl2019@mail.ustc.edu.cn> To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org Cc: linux-hyperv@vger.kernel.org, Lv Yunlong <lyl2019@mail.ustc.edu.cn>, linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] video/fbdev: Fix a double free in hvfb_probe Date: Tue, 23 Mar 2021 00:33:50 -0700 [thread overview] Message-ID: <20210323073350.17697-1-lyl2019@mail.ustc.edu.cn> (raw) 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 <lyl2019@mail.ustc.edu.cn> --- drivers/video/fbdev/hyperv_fb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c index c8b0ae676809..2fc9b507e73a 100644 --- a/drivers/video/fbdev/hyperv_fb.c +++ b/drivers/video/fbdev/hyperv_fb.c @@ -1032,6 +1032,7 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info) if (!pdev) { pr_err("Unable to find PCI Hyper-V video\n"); kfree(info->apertures); + info->apertures = NULL; return -ENODEV; } @@ -1130,6 +1131,7 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info) pci_dev_put(pdev); } kfree(info->apertures); + info->apertures = NULL; return 0; @@ -1142,6 +1144,7 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info) if (!gen2vm) pci_dev_put(pdev); kfree(info->apertures); + info->apertures = NULL; return -ENOMEM; } -- 2.25.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
next reply other threads:[~2021-03-23 7:35 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-23 7:33 Lv Yunlong [this message] 2021-03-23 7:33 ` [PATCH] video/fbdev: Fix a double free in hvfb_probe Lv Yunlong 2021-03-23 11:28 ` Wei Liu 2021-03-23 11:28 ` Wei Liu 2021-03-23 18:52 ` Michael Kelley 2021-03-23 18:52 ` Michael Kelley 2021-03-24 10:24 ` lyl2019 2021-03-24 10:24 ` lyl2019
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210323073350.17697-1-lyl2019@mail.ustc.edu.cn \ --to=lyl2019@mail.ustc.edu.cn \ --cc=dri-devel@lists.freedesktop.org \ --cc=haiyangz@microsoft.com \ --cc=kys@microsoft.com \ --cc=linux-fbdev@vger.kernel.org \ --cc=linux-hyperv@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=sthemmin@microsoft.com \ --cc=wei.liu@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.