All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/char/vt.c: check kmalloc() return value.
@ 2007-03-09  7:27 Amit Choudhary
  2007-03-09 12:19 ` Alan Cox
  0 siblings, 1 reply; 2+ messages in thread
From: Amit Choudhary @ 2007-03-09  7:27 UTC (permalink / raw)
  To: Linux Kernel

Description: Check the return value of kmalloc() in function con_init(), in file drivers/char/vt.c.

Signed-off-by: Amit Choudhary <amit2030@gmail.com>

diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 87587b4..6aa08cb 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -2640,6 +2640,15 @@ static int __init con_init(void)
 	 */
 	for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
 		vc_cons[currcons].d = vc = alloc_bootmem(sizeof(struct vc_data));
+		if (!vc_cons[currcons].d) {
+			for (--currcons; currcons >= 0; currcons--) {
+				kfree(vc_cons[currcons].d);
+				vc_cons[currcons].d = NULL;
+			}
+			release_console_sem();
+			return -ENOMEM;
+		}
+
 		visual_init(vc, currcons, 1);
 		vc->vc_screenbuf = (unsigned short *)alloc_bootmem(vc->vc_screenbuf_size);
 		vc->vc_kmalloced = 0;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-09 11:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-09  7:27 [PATCH] drivers/char/vt.c: check kmalloc() return value Amit Choudhary
2007-03-09 12:19 ` Alan Cox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.