From: Cyrill Gorcunov <gorcunov@gmail.com>
Date: Tue, 1 Apr 2008 19:48:23 +0000 (-0300)
Subject: V4L/DVB (7460): bttv: Bt832 - fix possible NULL pointer deref
X-Git-Tag: v2.6.25-rc9~56^2~2
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4a8f3a5727c589a59bcaaca43dc1025b347b7a75;p=users%2Fdwmw2%2Flinux.git

V4L/DVB (7460): bttv: Bt832 - fix possible NULL pointer deref

This patch does fix potential NULL pointer dereference

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
---

diff --git a/drivers/media/video/bt8xx/bt832.c b/drivers/media/video/bt8xx/bt832.c
index a51876137880b..f92f06dec0d0a 100644
--- a/drivers/media/video/bt8xx/bt832.c
+++ b/drivers/media/video/bt8xx/bt832.c
@@ -97,6 +97,11 @@ int bt832_init(struct i2c_client *i2c_client_s)
 	int rc;
 
 	buf=kmalloc(65,GFP_KERNEL);
+	if (!buf) {
+		v4l_err(&t->client,
+			"Unable to allocate memory. Detaching.\n");
+		return 0;
+	}
 	bt832_hexdump(i2c_client_s,buf);
 
 	if(buf[0x40] != 0x31) {
@@ -211,7 +216,12 @@ bt832_command(struct i2c_client *client, unsigned int cmd, void *arg)
 	switch (cmd) {
 		case BT832_HEXDUMP: {
 			unsigned char *buf;
-			buf=kmalloc(65,GFP_KERNEL);
+			buf = kmalloc(65, GFP_KERNEL);
+			if (!buf) {
+				v4l_err(&t->client,
+					"Unable to allocate memory\n");
+				break;
+			}
 			bt832_hexdump(&t->client,buf);
 			kfree(buf);
 		}