提交 8df327c3 编写于 作者: E Ernesto Ramos 提交者: Greg Kroah-Hartman

staging: ti dspbridge: avoid errors if node handle is zero

As 'zero' can be a perfectly good id, it can be picked up as
a NULL from userspace, avoid issues in API and user apps if node
handle is zero.
Signed-off-by: NErnesto Ramos <ernesto@ti.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 0624f52f
...@@ -1059,7 +1059,7 @@ inline void find_node_handle(struct node_res_object **noderes, ...@@ -1059,7 +1059,7 @@ inline void find_node_handle(struct node_res_object **noderes,
{ {
rcu_read_lock(); rcu_read_lock();
*noderes = idr_find(((struct process_context *)pr_ctxt)->node_id, *noderes = idr_find(((struct process_context *)pr_ctxt)->node_id,
(int)hnode); (int)hnode - 1);
rcu_read_unlock(); rcu_read_unlock();
return; return;
} }
...@@ -1077,6 +1077,7 @@ u32 nodewrap_allocate(union trapped_args *args, void *pr_ctxt) ...@@ -1077,6 +1077,7 @@ u32 nodewrap_allocate(union trapped_args *args, void *pr_ctxt)
u8 *pargs = NULL; u8 *pargs = NULL;
struct dsp_nodeattrin proc_attr_in, *attr_in = NULL; struct dsp_nodeattrin proc_attr_in, *attr_in = NULL;
struct node_res_object *node_res; struct node_res_object *node_res;
int nodeid;
/* Optional argument */ /* Optional argument */
if (psize) { if (psize) {
...@@ -1112,7 +1113,8 @@ u32 nodewrap_allocate(union trapped_args *args, void *pr_ctxt) ...@@ -1112,7 +1113,8 @@ u32 nodewrap_allocate(union trapped_args *args, void *pr_ctxt)
attr_in, &node_res, pr_ctxt); attr_in, &node_res, pr_ctxt);
} }
if (!status) { if (!status) {
CP_TO_USR(args->args_node_allocate.ph_node, &node_res->id, nodeid = node_res->id + 1;
CP_TO_USR(args->args_node_allocate.ph_node, &nodeid,
status, 1); status, 1);
if (status) { if (status) {
status = -EFAULT; status = -EFAULT;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册