From: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
To: linux-fbdev@vger.kernel.org
Subject: Re: [PATCH] video: fbdev: imxfb: use after free in imxfb_remove()
Date: Tue, 04 Jul 2017 15:44:57 +0000 [thread overview]
Message-ID: <2088323.70idy6k2dB@amdc3058> (raw)
In-Reply-To: <20170630080242.emnw7l53f52pvzeo@mwanda>
Hi,
On Friday, June 30, 2017 11:02:42 AM Dan Carpenter wrote:
> We free "info" then dereference it on the next line. I've moved the
> call to framebuffer_release() down a line to avoid this problem.
>
> Fixes: b7d2d37276c1 ("video: imxfb: Remove unused fields from platform data structure")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c
> index c166e0725be5..1d0c3592b290 100644
> --- a/drivers/video/fbdev/imxfb.c
> +++ b/drivers/video/fbdev/imxfb.c
> @@ -1080,10 +1080,9 @@ static int imxfb_remove(struct platform_device *pdev)
>
> fb_dealloc_cmap(&info->cmap);
> kfree(info->pseudo_palette);
> - framebuffer_release(info);
> -
> dma_free_wc(&pdev->dev, fbi->map_size, info->screen_base,
> fbi->map_dma);
> + framebuffer_release(info);
>
> iounmap(fbi->regs);
Good catch.
While you are at it, please:
- move framebuffer_release() after iounmap() (memory occupied by
fbi will also be freed by framebuffer_release() call, please see
framebuffer_alloc() for details)
- make the ordering in imxfb_remove() match the ordering of error
path in imxfb_probe() (to improve consistency and prevent similar
ordering errors in future)
> release_mem_region(res->start, resource_size(res));
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
next prev parent reply other threads:[~2017-07-04 15:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-30 8:02 [PATCH] video: fbdev: imxfb: use after free in imxfb_remove() Dan Carpenter
2017-07-04 15:44 ` Bartlomiej Zolnierkiewicz [this message]
2017-07-05 12:02 ` Dan Carpenter
2017-07-06 10:04 ` Bartlomiej Zolnierkiewicz
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=2088323.70idy6k2dB@amdc3058 \
--to=b.zolnierkie@samsung.com \
--cc=linux-fbdev@vger.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).