summaryrefslogtreecommitdiff
path: root/plugins/ofono.c
diff options
context:
space:
mode:
authorPekka Pessi <Pekka.Pessi@nokia.com>2010-08-26 17:26:43 +0300
committerSamuel Ortiz <sameo@linux.intel.com>2010-09-09 20:44:41 +0200
commit538b43ae9e3e7592f7f758e70b86bf2d97093bb9 (patch)
tree5d3413caf5215c74bded74930b5b71b3818dd490 /plugins/ofono.c
parent2d1ec537c78d2a9746c2733754922109916c087a (diff)
downloadconnman-538b43ae9e3e7592f7f758e70b86bf2d97093bb9.tar.gz
connman-538b43ae9e3e7592f7f758e70b86bf2d97093bb9.tar.bz2
connman-538b43ae9e3e7592f7f758e70b86bf2d97093bb9.zip
ofono: fix add_network()
Protect against duplication, remove leak.
Diffstat (limited to 'plugins/ofono.c')
-rw-r--r--plugins/ofono.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/plugins/ofono.c b/plugins/ofono.c
index 7d686a30..9e022b9f 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -654,18 +654,19 @@ static void add_network(struct connman_device *device, const char *path)
DBG("device %p path %s", device, path);
- network = connman_device_get_network(device, path);
+ ident = get_ident(path);
+
+ network = connman_device_get_network(device, ident);
if (network != NULL)
return;
- ident = get_ident(path);
-
- network = connman_network_create(ident,
- CONNMAN_NETWORK_TYPE_CELLULAR);
+ network = connman_network_create(ident, CONNMAN_NETWORK_TYPE_CELLULAR);
if (network == NULL)
return;
- connman_network_set_string(network, "Path", path);
+ if (connman_network_set_string(network, "Path", path) != 0)
+ goto error;
+
connman_network_set_available(network, TRUE);
connman_network_set_index(network, -1);
@@ -677,7 +678,11 @@ static void add_network(struct connman_device *device, const char *path)
if (mnc != NULL)
connman_network_set_string(network, "Cellular.MNC", mnc);
- connman_device_add_network(device, network);
+ if (connman_device_add_network(device, network) == 0)
+ return;
+
+error:
+ connman_network_unref(network);
}
static void add_networks(struct connman_device *device, DBusMessageIter *array)