Skip to contentSkip to conversation

drivers/char/vt.c: check kmalloc() return value.

PATCH In review Amit Choudhary 2 participants 2 messages Mar 9, 2007 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/char/vt.c: check kmalloc() return value.

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

drivers/char/vt.c +9 -0
index 87587b4..6aa08cb 100644
@@ -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;
#1 lore raw
Quoted 1 line · On Thu, 8 Mar 2007 23:27:13 -0800 Amit Choudhary <[email protected]> wrote:

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

NAK; This occurs at boot and if it fails we are wasting our time recovering.

Alan