Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: ti dspbridge: avoid errors if stream id 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 stream
handle is zero.

Signed-off-by: Ernesto Ramos <ernesto@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Ernesto Ramos and committed by
Greg Kroah-Hartman
084f70ee 4ec09714

+6 -2
+6 -2
drivers/staging/tidspbridge/pmgr/dspapi.c
··· 1527 1527 { 1528 1528 rcu_read_lock(); 1529 1529 *strmres = idr_find(((struct process_context *)pr_ctxt)->stream_id, 1530 - (int)hstream); 1530 + (int)hstream - 1); 1531 1531 rcu_read_unlock(); 1532 1532 return; 1533 1533 } ··· 1724 1724 struct strm_res_object *strm_res_obj; 1725 1725 struct dsp_streamattrin strm_attr_in; 1726 1726 struct node_res_object *node_res; 1727 + int strmid; 1727 1728 1728 1729 find_node_handle(&node_res, pr_ctxt, args->args_strm_open.hnode); 1729 1730 ··· 1746 1745 args->args_strm_open.direction, 1747 1746 args->args_strm_open.index, &attr, &strm_res_obj, 1748 1747 pr_ctxt); 1749 - CP_TO_USR(args->args_strm_open.ph_stream, &strm_res_obj->id, status, 1); 1748 + if (!status) { 1749 + strmid = strm_res_obj->id + 1; 1750 + CP_TO_USR(args->args_strm_open.ph_stream, &strmid, status, 1); 1751 + } 1750 1752 return status; 1751 1753 } 1752 1754