diff mbox

[OpenWrt-Devel,netifd,7/7] device: Drop device down event during device release if device gets active again

Message ID 1474636103-25093-7-git-send-email-dedeckeh@gmail.com
State Changes Requested
Delegated to: John Crispin
Headers show

Commit Message

Hans Dedecker Sept. 23, 2016, 1:08 p.m. UTC
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>
---
 device.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox

Patch

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);
 }