From: Ernesto Ramos <ernesto@ti.com>
To: gregkh@suse.de
Cc: omar.ramirez@ti.com, ohad@wizery.com, ameya.palande@nokia.com,
felipe.contreras@nokia.com, fernando.lugo@ti.com,
linux-kernel@vger.kernel.org, andy.shevchenko@gmail.com,
nm@ti.com, linux-omap@vger.kernel.org,
Ernesto Ramos <ernesto@ti.com>
Subject: [PATCH] staging:ti dspbridge: avoid errors if stream id is zero
Date: Wed, 28 Jul 2010 16:04:57 -0500 [thread overview]
Message-ID: <1280351097-3346-6-git-send-email-ernesto@ti.com> (raw)
In-Reply-To: <1280351097-3346-5-git-send-email-ernesto@ti.com>
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>
---
drivers/staging/tidspbridge/pmgr/dspapi.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/tidspbridge/pmgr/dspapi.c b/drivers/staging/tidspbridge/pmgr/dspapi.c
index 47892dd..7b42f72 100644
--- a/drivers/staging/tidspbridge/pmgr/dspapi.c
+++ b/drivers/staging/tidspbridge/pmgr/dspapi.c
@@ -1527,7 +1527,7 @@ inline void find_strm_handle(struct strm_res_object **strmres,
{
rcu_read_lock();
*strmres = idr_find(((struct process_context *)pr_ctxt)->stream_id,
- (int)hstream);
+ (int)hstream - 1);
rcu_read_unlock();
return;
}
@@ -1724,6 +1724,7 @@ u32 strmwrap_open(union trapped_args *args, void *pr_ctxt)
struct strm_res_object *strm_res_obj;
struct dsp_streamattrin strm_attr_in;
struct node_res_object *node_res;
+ int strmid;
find_node_handle(&node_res, pr_ctxt, args->args_strm_open.hnode);
@@ -1745,7 +1746,10 @@ u32 strmwrap_open(union trapped_args *args, void *pr_ctxt)
args->args_strm_open.direction,
args->args_strm_open.index, &attr, &strm_res_obj,
pr_ctxt);
- CP_TO_USR(args->args_strm_open.ph_stream, &strm_res_obj->id, status, 1);
+ if (!status) {
+ strmid = strm_res_obj->id + 1;
+ CP_TO_USR(args->args_strm_open.ph_stream, &strmid, status, 1);
+ }
return status;
}
--
1.5.4.5
prev parent reply other threads:[~2010-07-28 21:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-28 21:04 [PATCH 0/5] use idr kernel library instead of handles Ernesto Ramos
2010-07-28 21:04 ` [PATCH] staging:ti dspbridge: use node id instead of kernel address Ernesto Ramos
2010-07-28 21:04 ` [PATCH] staging:ti dspbridge: avoid errors if node handle is zero Ernesto Ramos
2010-07-28 21:04 ` [PATCH] staging:ti dspbridge: use processor handle from context instead of user's Ernesto Ramos
2010-07-28 21:04 ` [PATCH] staging:ti dspbridge: use stream id instead of kernel address Ernesto Ramos
2010-07-28 21:04 ` Ernesto Ramos [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1280351097-3346-6-git-send-email-ernesto@ti.com \
--to=ernesto@ti.com \
--cc=ameya.palande@nokia.com \
--cc=andy.shevchenko@gmail.com \
--cc=felipe.contreras@nokia.com \
--cc=fernando.lugo@ti.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=nm@ti.com \
--cc=ohad@wizery.com \
--cc=omar.ramirez@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®