aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2009-07-16 11:06:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-07-16 12:19:16 -0400
commit5c9228f0cfb09a098a8a380116b42ae099e967b6 (patch)
treef3306b2a1e53309b876d5d2543ad6fa85ae66caf
parentff5392d77bbb0746d1a034e955231f03ffc30b61 (diff)
vt: drop bootmem/slab memory distinction
Bootmem is not used for the vt screen buffer anymore as slab is now available at the time the console is initialized. Get rid of the now superfluous distinction between slab and bootmem, it's always slab. This also fixes a kmalloc leak which Catalin described thusly: Commit a5f4f52e ("vt: use kzalloc() instead of the bootmem allocator") replaced the alloc_bootmem() with kzalloc() but didn't set vc_kmalloced to 1 and the memory block is later leaked. The corresponding kmemleak trace: unreferenced object 0xdf828000 (size 8192): comm "swapper", pid 0, jiffies 4294937296 backtrace: [<c006d473>] __save_stack_trace+0x17/0x1c [<c000d869>] log_early+0x55/0x84 [<c01cfa4b>] kmemleak_alloc+0x33/0x3c [<c006c013>] __kmalloc+0xd7/0xe4 [<c00108c7>] con_init+0xbf/0x1b8 [<c0010149>] console_init+0x11/0x20 [<c0008797>] start_kernel+0x137/0x1e4 Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Reviewed-by: Pekka Enberg <penberg@cs.helsinki.fi> Tested-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/char/vt.c12
-rw-r--r--include/linux/console_struct.h1
2 files changed, 3 insertions, 10 deletions
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 7947bd1b4cf7..404f4c1ee431 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -770,14 +770,12 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */
770 visual_init(vc, currcons, 1); 770 visual_init(vc, currcons, 1);
771 if (!*vc->vc_uni_pagedir_loc) 771 if (!*vc->vc_uni_pagedir_loc)
772 con_set_default_unimap(vc); 772 con_set_default_unimap(vc);
773 if (!vc->vc_kmalloced) 773 vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL);
774 vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL);
775 if (!vc->vc_screenbuf) { 774 if (!vc->vc_screenbuf) {
776 kfree(vc); 775 kfree(vc);
777 vc_cons[currcons].d = NULL; 776 vc_cons[currcons].d = NULL;
778 return -ENOMEM; 777 return -ENOMEM;
779 } 778 }
780 vc->vc_kmalloced = 1;
781 vc_init(vc, vc->vc_rows, vc->vc_cols, 1); 779 vc_init(vc, vc->vc_rows, vc->vc_cols, 1);
782 vcs_make_sysfs(currcons); 780 vcs_make_sysfs(currcons);
783 atomic_notifier_call_chain(&vt_notifier_list, VT_ALLOCATE, &param); 781 atomic_notifier_call_chain(&vt_notifier_list, VT_ALLOCATE, &param);
@@ -913,10 +911,8 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
913 if (new_scr_end > new_origin) 911 if (new_scr_end > new_origin)
914 scr_memsetw((void *)new_origin, vc->vc_video_erase_char, 912 scr_memsetw((void *)new_origin, vc->vc_video_erase_char,
915 new_scr_end - new_origin); 913 new_scr_end - new_origin);
916 if (vc->vc_kmalloced) 914 kfree(vc->vc_screenbuf);
917 kfree(vc->vc_screenbuf);
918 vc->vc_screenbuf = newscreen; 915 vc->vc_screenbuf = newscreen;
919 vc->vc_kmalloced = 1;
920 vc->vc_screenbuf_size = new_screen_size; 916 vc->vc_screenbuf_size = new_screen_size;
921 set_origin(vc); 917 set_origin(vc);
922 918
@@ -995,8 +991,7 @@ void vc_deallocate(unsigned int currcons)
995 vc->vc_sw->con_deinit(vc); 991 vc->vc_sw->con_deinit(vc);
996 put_pid(vc->vt_pid); 992 put_pid(vc->vt_pid);
997 module_put(vc->vc_sw->owner); 993 module_put(vc->vc_sw->owner);
998 if (vc->vc_kmalloced) 994 kfree(vc->vc_screenbuf);
999 kfree(vc->vc_screenbuf);
1000 if (currcons >= MIN_NR_CONSOLES) 995 if (currcons >= MIN_NR_CONSOLES)
1001 kfree(vc); 996 kfree(vc);
1002 vc_cons[currcons].d = NULL; 997 vc_cons[currcons].d = NULL;
@@ -2881,7 +2876,6 @@ static int __init con_init(void)
2881 INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK); 2876 INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
2882 visual_init(vc, currcons, 1); 2877 visual_init(vc, currcons, 1);
2883 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT); 2878 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT);
2884 vc->vc_kmalloced = 0;
2885 vc_init(vc, vc->vc_rows, vc->vc_cols, 2879 vc_init(vc, vc->vc_rows, vc->vc_cols,
2886 currcons || !vc->vc_sw->con_save_screen); 2880 currcons || !vc->vc_sw->con_save_screen);
2887 } 2881 }
diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
index d71f7c0f931b..38fe59dc89ae 100644
--- a/include/linux/console_struct.h
+++ b/include/linux/console_struct.h
@@ -89,7 +89,6 @@ struct vc_data {
89 unsigned int vc_need_wrap : 1; 89 unsigned int vc_need_wrap : 1;
90 unsigned int vc_can_do_color : 1; 90 unsigned int vc_can_do_color : 1;
91 unsigned int vc_report_mouse : 2; 91 unsigned int vc_report_mouse : 2;
92 unsigned int vc_kmalloced : 1;
93 unsigned char vc_utf : 1; /* Unicode UTF-8 encoding */ 92 unsigned char vc_utf : 1; /* Unicode UTF-8 encoding */
94 unsigned char vc_utf_count; 93 unsigned char vc_utf_count;
95 int vc_utf_char; 94 int vc_utf_char;