All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amit Choudhary <amit2030@gmail.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] drivers/char/vt.c: check kmalloc() return value.
Date: Thu, 8 Mar 2007 23:27:13 -0800	[thread overview]
Message-ID: <20070308232713.ef9c608e.amit2030@gmail.com> (raw)

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;

             reply	other threads:[~2007-03-09  7:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-09  7:27 Amit Choudhary [this message]
2007-03-09 12:19 ` [PATCH] drivers/char/vt.c: check kmalloc() return value Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070308232713.ef9c608e.amit2030@gmail.com \
    --to=amit2030@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.