* [PATCH] video: fbdev: w100fb: Fix a potential double free.
@ 2020-04-27 9:19 Christophe JAILLET
2020-05-06 17:48 ` Sam Ravnborg
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2020-04-27 9:19 UTC (permalink / raw)
To: b.zolnierkie, gregkh, kstewart, tglx, arnd, jani.nikula, akpm,
adaplas, rpurdie
Cc: Christophe JAILLET, linux-fbdev, kernel-janitors, linux-kernel,
dri-devel
Some memory is vmalloc'ed in the 'suspend' function and freed in the
'resume' function.
However, it is also freed in the remove function.
In order to avoid a potential double free, set the corresponding pointer
to NULL once freed in the 'resume' function.
Fixes: aac51f09d96a ("[PATCH] w100fb: Rewrite for platform independence")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/video/fbdev/w100fb.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/video/fbdev/w100fb.c b/drivers/video/fbdev/w100fb.c
index 2d6e2738b792..d96ab28f8ce4 100644
--- a/drivers/video/fbdev/w100fb.c
+++ b/drivers/video/fbdev/w100fb.c
@@ -588,6 +588,7 @@ static void w100fb_restore_vidmem(struct w100fb_par *par)
memsize=par->mach->mem->size;
memcpy_toio(remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), par->saved_extmem, memsize);
vfree(par->saved_extmem);
+ par->saved_extmem = NULL;
}
if (par->saved_intmem) {
memsize=MEM_INT_SIZE;
@@ -596,6 +597,7 @@ static void w100fb_restore_vidmem(struct w100fb_par *par)
else
memcpy_toio(remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), par->saved_intmem, memsize);
vfree(par->saved_intmem);
+ par->saved_intmem = NULL;
}
}
--
2.25.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] video: fbdev: w100fb: Fix a potential double free.
2020-04-27 9:19 [PATCH] video: fbdev: w100fb: Fix a potential double free Christophe JAILLET
@ 2020-05-06 17:48 ` Sam Ravnborg
0 siblings, 0 replies; 2+ messages in thread
From: Sam Ravnborg @ 2020-05-06 17:48 UTC (permalink / raw)
To: Christophe JAILLET
Cc: kstewart, akpm, linux-fbdev, arnd, b.zolnierkie, jani.nikula,
gregkh, kernel-janitors, linux-kernel, dri-devel, rpurdie,
adaplas, tglx
Hi Christophe
On Mon, Apr 27, 2020 at 11:19:45AM +0200, Christophe JAILLET wrote:
> Some memory is vmalloc'ed in the 'suspend' function and freed in the
> 'resume' function.
> However, it is also freed in the remove function.
>
> In order to avoid a potential double free, set the corresponding pointer
> to NULL once freed in the 'resume' function.
The changelog talks about a suspend and a resume function.
But the code has a w100fb_save_vidmem() and a w100fb_restore_vidmem()
functions.
>
> Fixes: aac51f09d96a ("[PATCH] w100fb: Rewrite for platform independence")
This "Fixes" should be followed by:
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Antonino Daplas <adaplas@pol.net>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: <stable@vger.kernel.org> # v2.6.14+
This is the output of "dim fixes" - that does some magic to provide
the above list.
I filtered a few candidates out that should not be there.
Please fix both issues and resend.
Thanks,
Sam
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/video/fbdev/w100fb.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/video/fbdev/w100fb.c b/drivers/video/fbdev/w100fb.c
> index 2d6e2738b792..d96ab28f8ce4 100644
> --- a/drivers/video/fbdev/w100fb.c
> +++ b/drivers/video/fbdev/w100fb.c
> @@ -588,6 +588,7 @@ static void w100fb_restore_vidmem(struct w100fb_par *par)
> memsize=par->mach->mem->size;
> memcpy_toio(remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), par->saved_extmem, memsize);
> vfree(par->saved_extmem);
> + par->saved_extmem = NULL;
> }
> if (par->saved_intmem) {
> memsize=MEM_INT_SIZE;
> @@ -596,6 +597,7 @@ static void w100fb_restore_vidmem(struct w100fb_par *par)
> else
> memcpy_toio(remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), par->saved_intmem, memsize);
> vfree(par->saved_intmem);
> + par->saved_intmem = NULL;
> }
> }
>
> --
> 2.25.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-06 17:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-27 9:19 [PATCH] video: fbdev: w100fb: Fix a potential double free Christophe JAILLET
2020-05-06 17:48 ` Sam Ravnborg
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).