Skip to content

Commit

Permalink
fbcon: Move more code into fbcon_release
Browse files Browse the repository at this point in the history
con2fb_release_oldinfo() has a bunch more kfree() calls than
fbcon_exit(), but since kfree() on NULL is harmless doing that in both
places should be ok. This is also a bit more symmetric now again with
fbcon_open also allocating the fbcon_ops structure.

Acked-by: Sam Ravnborg <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: Tetsuo Handa <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Du Cheng <[email protected]>
Cc: Claudio Suarez <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
danvet committed Apr 7, 2022
1 parent 6e7da3a commit 3647d6d
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions drivers/video/fbdev/core/fbcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,18 @@ static void fbcon_release(struct fb_info *info)
unlock_fb_info(info);

module_put(info->fbops->owner);

if (info->fbcon_par) {
struct fbcon_ops *ops = info->fbcon_par;

fbcon_del_cursor_work(info);
kfree(ops->cursor_state.mask);
kfree(ops->cursor_data);
kfree(ops->cursor_src);
kfree(ops->fontbuffer);
kfree(info->fbcon_par);
info->fbcon_par = NULL;
}
}

static int fbcon_open(struct fb_info *info)
Expand Down Expand Up @@ -740,18 +752,10 @@ static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info,
static void con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldinfo,
struct fb_info *newinfo)
{
struct fbcon_ops *ops = oldinfo->fbcon_par;
int ret;

fbcon_release(oldinfo);

fbcon_del_cursor_work(oldinfo);
kfree(ops->cursor_state.mask);
kfree(ops->cursor_data);
kfree(ops->cursor_src);
kfree(ops->fontbuffer);
kfree(oldinfo->fbcon_par);
oldinfo->fbcon_par = NULL;
/*
If oldinfo and newinfo are driving the same hardware,
the fb_release() method of oldinfo may attempt to
Expand Down Expand Up @@ -3315,19 +3319,8 @@ static void fbcon_exit(void)
}
}

if (mapped) {
if (info->fbcon_par) {
struct fbcon_ops *ops = info->fbcon_par;

fbcon_del_cursor_work(info);
kfree(ops->cursor_src);
kfree(ops->cursor_state.mask);
kfree(info->fbcon_par);
info->fbcon_par = NULL;
}

if (mapped)
fbcon_release(info);
}
}
}

Expand Down

0 comments on commit 3647d6d

Please sign in to comment.