summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadoslaw Pajak <r.pajak@samsung.com>2013-11-08 14:16:50 (GMT)
committerJacek Janczyk <j.janczyk@samsung.com>2013-11-12 08:12:47 (GMT)
commit3180b3898465a180405c3d1317c8bf4860d3af32 (patch)
tree3d9067b157b7d64cc3e7e6963e80c3a045b79ed8
parent1a539da756d7d8783209216872976251e6dad767 (diff)
downloadkdbus-bus-kdbus-dev.zip
kdbus-bus-kdbus-dev.tar.gz
kdbus-bus-kdbus-dev.tar.bz2
Fixed memory freeing in match.ckdbus-dev
Change-Id: If3b7df12b8ded42ca7e98788482ad3369166e379 Signed-off-by: Radoslaw Pajak <r.pajak@samsung.com>
-rw-r--r--match.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/match.c b/match.c
index d001988..e8b33eb 100644
--- a/match.c
+++ b/match.c
@@ -307,10 +307,6 @@ int kdbus_match_db_add(struct kdbus_conn *conn, void __user *buf)
if (IS_ERR(cmd_match))
return PTR_ERR(cmd_match);
- e = kzalloc(sizeof(*e), GFP_KERNEL);
- if (!e)
- return -ENOMEM;
-
if (cmd_match->id != 0 && cmd_match->id != conn->id) {
struct kdbus_conn *targ_conn;
@@ -318,11 +314,19 @@ int kdbus_match_db_add(struct kdbus_conn *conn, void __user *buf)
cmd_match->id);
if (targ_conn)
db = targ_conn->match_db;
- else
- return -ENXIO;
+ else {
+ ret = -ENXIO;
+ goto exit_free;
+ }
} else
db = conn->match_db;
+ e = kzalloc(sizeof(*e), GFP_KERNEL);
+ if (!e) {
+ ret = -ENOMEM;
+ goto exit_free;
+ }
+
mutex_lock(&db->entries_lock);
INIT_LIST_HEAD(&e->list_entry);
INIT_LIST_HEAD(&e->items_list);
@@ -389,8 +393,9 @@ int kdbus_match_db_add(struct kdbus_conn *conn, void __user *buf)
}
mutex_unlock(&db->entries_lock);
- kfree(cmd_match);
+exit_free:
+ kfree(cmd_match);
return ret;
}
@@ -411,8 +416,10 @@ int kdbus_match_db_remove(struct kdbus_conn *conn, void __user *buf)
cmd_match->id);
if (targ_conn)
db = targ_conn->match_db;
- else
+ else {
+ kfree(cmd_match);
return -ENXIO;
+ }
} else
db = conn->match_db;