device: Remove power pending timeout iff there is a pending request
authorSamuel Ortiz <sameo@linux.intel.com>
Thu, 25 Aug 2011 15:34:06 +0000 (17:34 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 25 Aug 2011 16:44:27 +0000 (18:44 +0200)
In the ethernet case, there won't be any.

src/device.c

index cdd9118..a5b815f 100644 (file)
@@ -663,9 +663,12 @@ int connman_device_set_powered(struct connman_device *device,
        if (device->powered == powered)
                return -EALREADY;
 
-       /* Reset pending request */
-       g_source_remove(device->pending_timeout);
-       device->pending_timeout = 0;
+       if (device->pending_timeout) {
+               /* Reset pending request */
+               g_source_remove(device->pending_timeout);
+               device->pending_timeout = 0;
+       }
+
        device->powered_pending = PENDING_NONE;
 
        device->powered = powered;