summaryrefslogtreecommitdiff
path: root/cmds/servicemanager/binder.c
diff options
context:
space:
mode:
author Serban Constantinescu <serban.constantinescu@arm.com> 2014-01-30 15:16:45 +0000
committer David Butcher <david.butcher@arm.com> 2014-01-31 10:49:20 +0000
commita44542ca74b7da5b44ba30c205c3244805bb0600 (patch)
tree5f95a0431cb0c0cab55e21ff4bdd464d5a9684ce /cmds/servicemanager/binder.c
parentdc832dc5513f0767c153f90a57356c3466f45dd4 (diff)
ServiceManager: Add extra error handling
This patch extends the error handling. It also adds a check for a matching binder version - kernel/userspace. Change-Id: I43a262934b38c5711536aaa42754fed1ef04b39e Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
Diffstat (limited to 'cmds/servicemanager/binder.c')
-rw-r--r--cmds/servicemanager/binder.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/cmds/servicemanager/binder.c b/cmds/servicemanager/binder.c
index 43cb7d35ce..7fdd841edd 100644
--- a/cmds/servicemanager/binder.c
+++ b/cmds/servicemanager/binder.c
@@ -94,6 +94,7 @@ struct binder_state
struct binder_state *binder_open(unsigned mapsize)
{
struct binder_state *bs;
+ struct binder_version vers;
bs = malloc(sizeof(*bs));
if (!bs) {
@@ -108,6 +109,12 @@ struct binder_state *binder_open(unsigned mapsize)
goto fail_open;
}
+ if ((ioctl(bs->fd, BINDER_VERSION, &vers) == -1) ||
+ (vers.protocol_version != BINDER_CURRENT_PROTOCOL_VERSION)) {
+ fprintf(stderr, "binder: driver version differs from user space\n");
+ goto fail_open;
+ }
+
bs->mapsize = mapsize;
bs->mapped = mmap(NULL, mapsize, PROT_READ, MAP_PRIVATE, bs->fd, 0);
if (bs->mapped == MAP_FAILED) {
@@ -116,8 +123,6 @@ struct binder_state *binder_open(unsigned mapsize)
goto fail_map;
}
- /* TODO: check version */
-
return bs;
fail_map: