Skip to content

Commit

Permalink
video/logo: prevent use of logos after they have been freed
Browse files Browse the repository at this point in the history
If the probe of an fb driver has been deferred due to missing
dependencies, and the probe is later ran when a module is loaded, the
fbdev framework will try to find a logo to use.

However, the logos are __initdata, and have already been freed. This
causes sometimes page faults, if the logo memory is not mapped,
sometimes other random crashes as the logo data is invalid, and
sometimes nothing, if the fbdev decides to reject the logo (e.g. the
random value depicting the logo's height is too big).

This patch adds a late_initcall function to mark the logos as freed. In
reality the logos are freed later, and fbdev probe may be ran between
this late_initcall and the freeing of the logos. In that case we will
miss drawing the logo, even if it would be possible.

Signed-off-by: Tomi Valkeinen <[email protected]>
Cc: [email protected]
  • Loading branch information
tomba committed Dec 29, 2014
1 parent 811174f commit 92b004d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion drivers/video/logo/logo.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ static bool nologo;
module_param(nologo, bool, 0);
MODULE_PARM_DESC(nologo, "Disables startup logo");

/*
* Logos are located in the initdata, and will be freed in kernel_init.
* Use late_init to mark the logos as freed to prevent any further use.
*/

static bool logos_freed;

static int __init fb_logo_late_init(void)
{
logos_freed = true;
return 0;
}

late_initcall(fb_logo_late_init);

/* logo's are marked __initdata. Use __init_refok to tell
* modpost that it is intended that this function uses data
* marked __initdata.
Expand All @@ -29,7 +44,7 @@ const struct linux_logo * __init_refok fb_find_logo(int depth)
{
const struct linux_logo *logo = NULL;

if (nologo)
if (nologo || logos_freed)
return NULL;

if (depth >= 1) {
Expand Down

0 comments on commit 92b004d

Please sign in to comment.