summaryrefslogtreecommitdiff
path: root/obexd
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2013-09-25 11:32:19 +0300
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2013-09-25 11:40:12 +0300
commitf4374b0790e4dd8a549c95ee8fbc12ba2d6a6248 (patch)
treeefdbdc25f5aea9d407fae6621e93f8c49c075a56 /obexd
parentd6b20f4df69ecaff11df5107b899b3297223cabe (diff)
obexd/service: Fix possible leaking drivers list
When registering a new driver with obex_service_driver_register there could exist another driver for the service which will cause the drivers list to leak.
Diffstat (limited to 'obexd')
-rw-r--r--obexd/src/service.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/obexd/src/service.c b/obexd/src/service.c
index 4d9ebfde8..6b8533b55 100644
--- a/obexd/src/service.c
+++ b/obexd/src/service.c
@@ -81,14 +81,30 @@ GSList *obex_service_driver_list(uint16_t services)
return list;
}
+static struct obex_service_driver *find_driver(uint16_t service)
+{
+ GSList *l;
+
+ for (l = drivers; l; l = l->next) {
+ struct obex_service_driver *driver = l->data;
+
+ if (driver->service == service)
+ return driver;
+ }
+
+ return NULL;
+}
+
int obex_service_driver_register(struct obex_service_driver *driver)
{
+ GSList *l;
+
if (!driver) {
error("Invalid driver");
return -EINVAL;
}
- if (obex_service_driver_list(driver->service)) {
+ if (find_driver(driver->service)) {
error("Permission denied: service %s already registered",
driver->name);
return -EPERM;