From: Dan Carpenter Date: Sat, 26 Mar 2011 01:52:22 +0000 (-0300) Subject: [media] pvrusb2: check for allocation failures X-Git-Tag: v3.0-rc1~47^2~177 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0cff593732fa5bdf07192be741a567b85a9c0cd3;p=profile%2Fivi%2Fkernel-adaptation-intel-automotive.git [media] 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... Signed-off-by: Dan Carpenter Acked-By: Mike Isely Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/video/pvrusb2/pvrusb2-std.c b/drivers/media/video/pvrusb2/pvrusb2-std.c index ca9f83a..35c8b40 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-std.c +++ b/drivers/media/video/pvrusb2/pvrusb2-std.c @@ -370,7 +370,11 @@ struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr, stddefs = kzalloc(sizeof(struct v4l2_standard) * std_cnt, GFP_KERNEL); - for (idx = 0; idx < std_cnt; idx++) stddefs[idx].index = idx; + if (!stddefs) + return NULL; + + for (idx = 0; idx < std_cnt; idx++) + stddefs[idx].index = idx; idx = 0;