summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2016-09-23 15:08:23 +0200
committerFelix Fietkau <nbd@nbd.name>2016-09-26 11:51:19 +0200
commit2bf80ba8c5ab4d01c6e8eb1b7ecebefea7f2d530 (patch)
treec60bc06c6cd9dfa0b3d5978e1617d6c1e201d172
parente2dfdffad514acf4f6a55f4608802421b55be236 (diff)
device: Drop device down event during device release if device gets active again
Fixes a race condition as the device can be active again; due to a device_claim; by the logic behind the set_state device type function. In this case the down event cannot be sent anymore as it would bring down the interface(s) referencing the device. This can be the case for an aliased device when the underlying device is switched during a reload; the alias_set_device function can add a new dependency on the new active device which will put the aliased device in active mode again as the aliased device is already claimed by the interface using it. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
-rw-r--r--device.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/device.c b/device.c
index e17df13..996ffab 100644
--- a/device.c
+++ b/device.c
@@ -450,6 +450,10 @@ void device_release(struct device_user *dep)
device_broadcast_event(dev, DEV_EVENT_TEARDOWN);
if (!dev->external)
dev->set_state(dev, false);
+
+ if (dev->active)
+ return;
+
device_broadcast_event(dev, DEV_EVENT_DOWN);
}