Commit c05df8b3 authored by Xiaochen Wang's avatar Xiaochen Wang Committed by Mauro Carvalho Chehab

[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: default avatarXiaochen Wang <wangxiaochen0@gmail.com>
Signed-off-by: default avatarMike Isely <isely@pobox.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 228ee592
...@@ -2850,15 +2850,23 @@ static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw) ...@@ -2850,15 +2850,23 @@ static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw)
PVR2_TRACE_ERROR_LEGS, PVR2_TRACE_ERROR_LEGS,
"WARNING: Failed to identify any viable standards"); "WARNING: Failed to identify any viable standards");
} }
/* Set up the dynamic control for this standard */
hdw->std_enum_names = kmalloc(sizeof(char *)*(std_cnt+1),GFP_KERNEL); hdw->std_enum_names = kmalloc(sizeof(char *)*(std_cnt+1),GFP_KERNEL);
if (hdw->std_enum_names) {
hdw->std_enum_names[0] = "none"; hdw->std_enum_names[0] = "none";
for (idx = 0; idx < std_cnt; idx++) { for (idx = 0; idx < std_cnt; idx++)
hdw->std_enum_names[idx+1] = hdw->std_enum_names[idx+1] = newstd[idx].name;
newstd[idx].name; hdw->std_info_enum.def.type_enum.value_names =
} hdw->std_enum_names;
// Set up the dynamic control for this standard
hdw->std_info_enum.def.type_enum.value_names = hdw->std_enum_names;
hdw->std_info_enum.def.type_enum.count = std_cnt+1; hdw->std_info_enum.def.type_enum.count = std_cnt+1;
} else {
pvr2_trace(
PVR2_TRACE_ERROR_LEGS,
"WARNING: Failed to alloc memory for names");
hdw->std_info_enum.def.type_enum.value_names = NULL;
hdw->std_info_enum.def.type_enum.count = 0;
}
hdw->std_defs = newstd; hdw->std_defs = newstd;
hdw->std_enum_cnt = std_cnt+1; hdw->std_enum_cnt = std_cnt+1;
hdw->std_enum_cur = 0; hdw->std_enum_cur = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment