From: Cyrill Gorcunov This patch does fix potential NULL pointer dereference Signed-off-by: Cyrill Gorcunov Cc: Mauro Carvalho Chehab Signed-off-by: Andrew Morton --- drivers/media/video/bt8xx/bt832.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff -puN drivers/media/video/bt8xx/bt832.c~bttv-bt832-fix-possible-null-pointer-deref drivers/media/video/bt8xx/bt832.c --- a/drivers/media/video/bt8xx/bt832.c~bttv-bt832-fix-possible-null-pointer-deref +++ a/drivers/media/video/bt8xx/bt832.c @@ -97,6 +97,11 @@ int bt832_init(struct i2c_client *i2c_cl 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, 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); } _