Skip to contentSkip to conversation

drivers/media/dvb/bt8xx/dvb-bt8xx.c: check kmalloc() return value.

PATCH In review Amit Choudhary 4 participants 7 messages Oct 9, 2006 – Oct 10, 2006 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/media/dvb/bt8xx/dvb-bt8xx.c: check kmalloc() return value.

Description: Check the return value of kmalloc() in function frontend_init(), in file drivers/media/dvb/bt8xx/dvb-bt8xx.c.

drivers/media/dvb/bt8xx/dvb-bt8xx.c +4 -0
index fb6c4cc..14e69a7 100644
@@ -665,6 +665,10 @@ static void frontend_init(struct dvb_bt8
 	case BTTV_BOARD_TWINHAN_DST:
 		/*	DST is not a frontend driver !!!		*/
 		state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
+		if (!state) {
+			printk("dvb_bt8xx: No memory\n");
+			break;
+		}
 		/*	Setup the Card					*/
 		state->config = &dst_config;
 		state->i2c = card->i2c_adapter;
#1 lore raw
Quoted 10 lines · Amit Choudhary

Description: Check the return value of kmalloc() in function frontend_init(), in file drivers/media/dvb/bt8xx/dvb-bt8xx.c.

drivers/media/dvb/bt8xx/dvb-bt8xx.c +0 -0
index fb6c4cc..14e69a7 100644
@@ -665,6 +665,10 @@ static void frontend_init(struct dvb_bt8
 	case BTTV_BOARD_TWINHAN_DST:

drivers/media/dvb/bt8xx/dvb-bt8xx.c static void frontend_init(struct dvb_bt8

Quoted 10 lines
drivers/media/dvb/bt8xx/dvb-bt8xx.c +4 -1
 		/*	DST is not a frontend driver !!!		*/
 		state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
+		if (!state) {
+			printk("dvb_bt8xx: No memory\n");
+			break;
+		}
 		/*	Setup the Card					*/
 		state->config = &dst_config;
 		state->i2c = card->i2c_adapter;
-

Thanks,
Manu

#5 lore raw
In reply to Amit Choudhary
Quoted 9 lines · Amit Choudhary

Description: Check the return value of kmalloc() in function frontend_init(), in file drivers/media/dvb/bt8xx/dvb-bt8xx.c.

drivers/media/dvb/bt8xx/dvb-bt8xx.c +0 -0
index fb6c4cc..14e69a7 100644

drivers/media/dvb/bt8xx/dvb-bt8xx.c static void frontend_init(struct dvb_bt8 · line 669

Quoted 5 lines
drivers/media/dvb/bt8xx/dvb-bt8xx.c +2 -0
@@ -665,6 +665,10 @@ static void frontend_init(struct dvb_bt8
 	case BTTV_BOARD_TWINHAN_DST:
 		/*	DST is not a frontend driver !!!		*/
 		state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
+		if (!state) {
+			printk("dvb_bt8xx: No memory\n");

KERN_FOO loglevel is missing.

#6 lore raw
Quoted 6 lines · Olaf Hering
Quoted 4 lines · Amit Choudhary

Description: Check the return value of kmalloc() in function frontend_init(), in file drivers/media/dvb/bt8xx/dvb-bt8xx.c.

Quoted 12 lines

drivers/media/dvb/bt8xx/dvb-bt8xx.c static void frontend_init(struct dvb_bt8 · line 669

Quoted 10 lines
drivers/media/dvb/bt8xx/dvb-bt8xx.c +2 -0
index fb6c4cc..14e69a7 100644
@@ -665,6 +665,10 @@ static void frontend_init(struct dvb_bt8
 	case BTTV_BOARD_TWINHAN_DST:
 		/*	DST is not a frontend driver !!!		*/
 		state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
+		if (!state) {
+			printk("dvb_bt8xx: No memory\n");

KERN_FOO loglevel is missing.

It shouldn't matter though.

Manu

#2 lore raw
In reply to Manu Abraham
Quoted 16 lines · Manu Abraham
Quoted 15 lines · Amit Choudhary

Description: Check the return value of kmalloc() in function frontend_init(), in file drivers/media/dvb/bt8xx/dvb-bt8xx.c.

drivers/media/dvb/bt8xx/dvb-bt8xx.c +3 -0
index fb6c4cc..14e69a7 100644
@@ -665,6 +665,10 @@ static void frontend_init(struct dvb_bt8
 	case BTTV_BOARD_TWINHAN_DST:
 		/*	DST is not a frontend driver !!!		*/
 		state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
+		if (!state) {
+			printk("dvb_bt8xx: No memory\n");
+			break;
Quoted 8 lines

drivers/media/dvb/bt8xx/dvb-bt8xx.c static void frontend_init(struct dvb_bt8

Quoted 5 lines
drivers/media/dvb/bt8xx/dvb-bt8xx.c +1 -1
+		}
 		/*	Setup the Card					*/
 		state->config = &dst_config;
 		state->i2c = card->i2c_adapter;
-

Care to send the full patch in a format that we can apply it to the -stable tree?

thanks,

greg k-h

#3 lore raw
Quoted 25 lines · Greg KH
Quoted 15 lines · Manu Abraham
Quoted 14 lines · Amit Choudhary

Description: Check the return value of kmalloc() in function frontend_init(), in file drivers/media/dvb/bt8xx/dvb-bt8xx.c.

drivers/media/dvb/bt8xx/dvb-bt8xx.c +2 -0
index fb6c4cc..14e69a7 100644
@@ -665,6 +665,10 @@ static void frontend_init(struct dvb_bt8
 	case BTTV_BOARD_TWINHAN_DST:
 		/*	DST is not a frontend driver !!!		*/
 		state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
+		if (!state) {
+			printk("dvb_bt8xx: No memory\n");
Quoted 8 lines

drivers/media/dvb/bt8xx/dvb-bt8xx.c static void frontend_init(struct dvb_bt8

Quoted 6 lines
drivers/media/dvb/bt8xx/dvb-bt8xx.c +2 -1
+			break;
+		}
 		/*	Setup the Card					*/
 		state->config = &dst_config;
 		state->i2c = card->i2c_adapter;
-
Quoted 3 lines

Care to send the full patch in a format that we can apply it to the -stable tree?

 dvb-bt8xx.c |    4 ++++
 1 files changed, 4 insertions(+)

Thanks,

Manu

drivers/media/dvb/bt8xx/dvb-bt8xx.c +4 -0
diff -Naurp linux-2.6.18.orig/drivers/media/dvb/bt8xx/dvb-bt8xx.c linux-2.6.18/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -666,6 +666,10 @@ static void frontend_init(struct dvb_bt8
 	case BTTV_BOARD_TWINHAN_DST:
 		/*	DST is not a frontend driver !!!		*/
 		state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
+		if (!state) {
+			printk("%s: Out of Memory !\n", __func__);
+			break;
+		}
 		/*	Setup the Card					*/
 		state->config = &dst_config;
 		state->i2c = card->i2c_adapter;
#4 lore raw
Quoted 31 lines · Manu Abraham
Quoted 25 lines · Greg KH
Quoted 15 lines · Manu Abraham
Quoted 14 lines · Amit Choudhary

Description: Check the return value of kmalloc() in function frontend_init(), in file drivers/media/dvb/bt8xx/dvb-bt8xx.c.

drivers/media/dvb/bt8xx/dvb-bt8xx.c +2 -0
index fb6c4cc..14e69a7 100644
@@ -665,6 +665,10 @@ static void frontend_init(struct dvb_bt8
 	case BTTV_BOARD_TWINHAN_DST:
 		/*	DST is not a frontend driver !!!		*/
 		state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
+		if (!state) {
+			printk("dvb_bt8xx: No memory\n");
Quoted 8 lines

drivers/media/dvb/bt8xx/dvb-bt8xx.c static void frontend_init(struct dvb_bt8

Quoted 6 lines
drivers/media/dvb/bt8xx/dvb-bt8xx.c +2 -1
+			break;
+		}
 		/*	Setup the Card					*/
 		state->config = &dst_config;
 		state->i2c = card->i2c_adapter;
-
Quoted 3 lines

Care to send the full patch in a format that we can apply it to the -stable tree?

Quoted 5 lines
 dvb-bt8xx.c |    4 ++++
 1 files changed, 4 insertions(+)

Thanks,

Um, can you resend it with the proper description and signed-off-by:
lines so that it can be applied correctly?

And does this solve a real bug, or is it just added error condition checks? If the latter, I don't think it's ok for -stable right now.

thanks,

greg k-h