aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorXiaochen Wang <wangxiaochen0@gmail.com>2011-03-13 21:32:53 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-22 03:54:37 -0400
commitc05df8b32ab4b8103f8c20cbd3ab7191be613b68 (patch)
tree3af2f634bd44ff82c1dda294e125edb2f3ac079a /drivers
parent228ee5928b5d4192a23cda3fdf755a956516c13e (diff)
[media] pvrusb2: check kmalloc return value
allows the driver to proceed and initialize the below two values even if the kmalloc() fails. hdw->std_info_enum.def.type_enum.value_names hdw->std_info_enum.def.type_enum.count Signed-off-by: Xiaochen Wang <wangxiaochen0@gmail.com> Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index d33dd61de263..9d0dd08f57f8 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -2850,15 +2850,23 @@ static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw)
2850 PVR2_TRACE_ERROR_LEGS, 2850 PVR2_TRACE_ERROR_LEGS,
2851 "WARNING: Failed to identify any viable standards"); 2851 "WARNING: Failed to identify any viable standards");
2852 } 2852 }
2853
2854 /* Set up the dynamic control for this standard */
2853 hdw->std_enum_names = kmalloc(sizeof(char *)*(std_cnt+1),GFP_KERNEL); 2855 hdw->std_enum_names = kmalloc(sizeof(char *)*(std_cnt+1),GFP_KERNEL);
2854 hdw->std_enum_names[0] = "none"; 2856 if (hdw->std_enum_names) {
2855 for (idx = 0; idx < std_cnt; idx++) { 2857 hdw->std_enum_names[0] = "none";
2856 hdw->std_enum_names[idx+1] = 2858 for (idx = 0; idx < std_cnt; idx++)
2857 newstd[idx].name; 2859 hdw->std_enum_names[idx+1] = newstd[idx].name;
2858 } 2860 hdw->std_info_enum.def.type_enum.value_names =
2859 // Set up the dynamic control for this standard 2861 hdw->std_enum_names;
2860 hdw->std_info_enum.def.type_enum.value_names = hdw->std_enum_names; 2862 hdw->std_info_enum.def.type_enum.count = std_cnt+1;
2861 hdw->std_info_enum.def.type_enum.count = std_cnt+1; 2863 } else {
2864 pvr2_trace(
2865 PVR2_TRACE_ERROR_LEGS,
2866 "WARNING: Failed to alloc memory for names");
2867 hdw->std_info_enum.def.type_enum.value_names = NULL;
2868 hdw->std_info_enum.def.type_enum.count = 0;
2869 }
2862 hdw->std_defs = newstd; 2870 hdw->std_defs = newstd;
2863 hdw->std_enum_cnt = std_cnt+1; 2871 hdw->std_enum_cnt = std_cnt+1;
2864 hdw->std_enum_cur = 0; 2872 hdw->std_enum_cur = 0;