Skip to contentSkip to conversation

pvrusb2: check for allocation failures

PATCH NAK Dan Carpenter 2 participants 4 messages Mar 26, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/6 pvrusb2: check for allocation failures

This function returns NULL on failure so lets do that if kzalloc() fails. There is a separate problem that the caller for this function doesn't check for errors...

drivers/media/video/pvrusb2/pvrusb2-std.c +3 -0
index 370a9ab..b214f77 100644
@@ -388,6 +388,9 @@ struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr,
 
 	stddefs = kzalloc(sizeof(struct v4l2_standard) * std_cnt,
 			  GFP_KERNEL);
+	if (!stddefs)
+		return NULL;
+
 	for (idx = 0; idx < std_cnt; idx++)
 		stddefs[idx].index = idx;
 
Acked-by on v1 3/6
#1 lore raw
Quoted 21 lines · Dan Carpenter

This function returns NULL on failure so lets do that if kzalloc() fails. There is a separate problem that the caller for this function doesn't check for errors...

drivers/media/video/pvrusb2/pvrusb2-std.c +3 -0
index 370a9ab..b214f77 100644
@@ -388,6 +388,9 @@ struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr,
 
 	stddefs = kzalloc(sizeof(struct v4l2_standard) * std_cnt,
 			  GFP_KERNEL);
+	if (!stddefs)
+		return NULL;
+
 	for (idx = 0; idx < std_cnt; idx++)
 		stddefs[idx].index = idx;
 
Signature · 3 lines
Mike Isely
isely @ isely (dot) net
PGP: 03 54 43 4D 75 E5 CC 92 71 16 01 E2 B5 F5 C1 E8
#3 lore raw

I'll look at the surrounding code and see what makes sense there. Having an error leg for allocation failures is a useful thing.

-Mike

Quoted 16 lines · Dan Carpenter
Quoted 3 lines · Mike Isely

I'd need to reformat this one to get it to apply... :/ It doesn't actually fix the bug so it's not worth it.

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
Mike Isely
isely @ isely (dot) net
PGP: 03 54 43 4D 75 E5 CC 92 71 16 01 E2 B5 F5 C1 E8