Commit cee49b3c authored by Rickard Strandqvist's avatar Rickard Strandqvist Committed by Greg Kroah-Hartman

staging: tidspbridge: pmgr: dspapi.c: Cleaning up uninitialized variable

There is a risk that the variables will be used without being initialized.
Has also improved error handling, after an email proposal from Dan Carpenter.
Signed-off-by: default avatarRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f4a8f528
...@@ -340,23 +340,23 @@ int api_init_complete2(void) ...@@ -340,23 +340,23 @@ int api_init_complete2(void)
u32 mgrwrap_enum_node_info(union trapped_args *args, void *pr_ctxt) u32 mgrwrap_enum_node_info(union trapped_args *args, void *pr_ctxt)
{ {
u8 *pndb_props; u8 *pndb_props;
u32 num_nodes; u32 num_nodes = 0;
int status = 0; int status;
u32 size = args->args_mgr_enumnode_info.ndb_props_size; u32 size = args->args_mgr_enumnode_info.ndb_props_size;
if (size < sizeof(struct dsp_ndbprops)) if (size < sizeof(struct dsp_ndbprops))
return -EINVAL; return -EINVAL;
size = sizeof(struct dsp_ndbprops);
pndb_props = kmalloc(size, GFP_KERNEL); pndb_props = kmalloc(size, GFP_KERNEL);
if (pndb_props == NULL) if (pndb_props == NULL)
status = -ENOMEM; return -ENOMEM;
if (!status) {
status = status =
mgr_enum_node_info(args->args_mgr_enumnode_info.node_id, mgr_enum_node_info(args->args_mgr_enumnode_info.node_id,
(struct dsp_ndbprops *)pndb_props, size, (struct dsp_ndbprops *)pndb_props, size,
&num_nodes); &num_nodes);
}
CP_TO_USR(args->args_mgr_enumnode_info.ndb_props, pndb_props, status, CP_TO_USR(args->args_mgr_enumnode_info.ndb_props, pndb_props, status,
size); size);
CP_TO_USR(args->args_mgr_enumnode_info.num_nodes, &num_nodes, status, CP_TO_USR(args->args_mgr_enumnode_info.num_nodes, &num_nodes, status,
...@@ -372,24 +372,26 @@ u32 mgrwrap_enum_node_info(union trapped_args *args, void *pr_ctxt) ...@@ -372,24 +372,26 @@ u32 mgrwrap_enum_node_info(union trapped_args *args, void *pr_ctxt)
u32 mgrwrap_enum_proc_info(union trapped_args *args, void *pr_ctxt) u32 mgrwrap_enum_proc_info(union trapped_args *args, void *pr_ctxt)
{ {
u8 *processor_info; u8 *processor_info;
u8 num_procs; u8 num_procs = 0;
int status = 0; int status;
u32 size = args->args_mgr_enumproc_info.processor_info_size; u32 size = args->args_mgr_enumproc_info.processor_info_size;
if (size < sizeof(struct dsp_processorinfo)) if (size < sizeof(struct dsp_processorinfo))
return -EINVAL; return -EINVAL;
processor_info = kmalloc(size, GFP_KERNEL); if (size > sizeof(struct mgr_processorextinfo))
size = sizeof(struct mgr_processorextinfo);
processor_info = kzalloc(size, GFP_KERNEL);
if (processor_info == NULL) if (processor_info == NULL)
status = -ENOMEM; return -ENOMEM;
if (!status) {
status = status =
mgr_enum_processor_info(args->args_mgr_enumproc_info. mgr_enum_processor_info(args->args_mgr_enumproc_info.
processor_id, processor_id,
(struct dsp_processorinfo *) (struct dsp_processorinfo *)
processor_info, size, &num_procs); processor_info, size, &num_procs);
}
CP_TO_USR(args->args_mgr_enumproc_info.processor_info, processor_info, CP_TO_USR(args->args_mgr_enumproc_info.processor_info, processor_info,
status, size); status, size);
CP_TO_USR(args->args_mgr_enumproc_info.num_procs, &num_procs, CP_TO_USR(args->args_mgr_enumproc_info.num_procs, &num_procs,
...@@ -475,11 +477,11 @@ u32 mgrwrap_wait_for_bridge_events(union trapped_args *args, void *pr_ctxt) ...@@ -475,11 +477,11 @@ u32 mgrwrap_wait_for_bridge_events(union trapped_args *args, void *pr_ctxt)
int status = 0; int status = 0;
struct dsp_notification *anotifications[MAX_EVENTS]; struct dsp_notification *anotifications[MAX_EVENTS];
struct dsp_notification notifications[MAX_EVENTS]; struct dsp_notification notifications[MAX_EVENTS];
u32 index, i; u32 index = 0, i;
u32 count = args->args_mgr_wait.count; u32 count = args->args_mgr_wait.count;
if (count > MAX_EVENTS) if (count > MAX_EVENTS)
status = -EINVAL; return -EINVAL;
/* get the array of pointers to user structures */ /* get the array of pointers to user structures */
CP_FM_USR(anotifications, args->args_mgr_wait.anotifications, CP_FM_USR(anotifications, args->args_mgr_wait.anotifications,
...@@ -487,19 +489,15 @@ u32 mgrwrap_wait_for_bridge_events(union trapped_args *args, void *pr_ctxt) ...@@ -487,19 +489,15 @@ u32 mgrwrap_wait_for_bridge_events(union trapped_args *args, void *pr_ctxt)
/* get the events */ /* get the events */
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
CP_FM_USR(&notifications[i], anotifications[i], status, 1); CP_FM_USR(&notifications[i], anotifications[i], status, 1);
if (status || !notifications[i].handle) { if (status || !notifications[i].handle)
status = -EINVAL; return -EINVAL;
break;
}
/* set the array of pointers to kernel structures */ /* set the array of pointers to kernel structures */
anotifications[i] = &notifications[i]; anotifications[i] = &notifications[i];
} }
if (!status) {
status = mgr_wait_for_bridge_events(anotifications, count, status = mgr_wait_for_bridge_events(anotifications, count,
&index, &index,
args->args_mgr_wait. args->args_mgr_wait.
timeout); timeout);
}
CP_TO_USR(args->args_mgr_wait.index, &index, status, 1); CP_TO_USR(args->args_mgr_wait.index, &index, status, 1);
return status; return status;
} }
...@@ -1755,7 +1753,7 @@ u32 strmwrap_register_notify(union trapped_args *args, void *pr_ctxt) ...@@ -1755,7 +1753,7 @@ u32 strmwrap_register_notify(union trapped_args *args, void *pr_ctxt)
*/ */
u32 strmwrap_select(union trapped_args *args, void *pr_ctxt) u32 strmwrap_select(union trapped_args *args, void *pr_ctxt)
{ {
u32 mask; u32 mask = 0;
struct strm_object *strm_tab[MAX_STREAMS]; struct strm_object *strm_tab[MAX_STREAMS];
int status = 0; int status = 0;
struct strm_res_object *strm_res; struct strm_res_object *strm_res;
......
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