From 5e24d501c585c53bae71ad28e5128d772b4446e2 Mon Sep 17 00:00:00 2001 From: Oron Peled Date: Sun, 6 Apr 2014 14:01:55 -0400 Subject: [PATCH] xpp: prevent double dahdi un-registration * It's currently harmless (just re-run the pre/post XPD registrations) * But it's cleaner this way (as with xbus_register_dahdi_device()) Signed-off-by: Tzafrir Cohen --- drivers/dahdi/xpp/xbus-core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c index a7bb798..d5ad1ec 100644 --- a/drivers/dahdi/xpp/xbus-core.c +++ b/drivers/dahdi/xpp/xbus-core.c @@ -1040,6 +1040,13 @@ void xbus_unregister_dahdi_device(xbus_t *xbus) XBUS_ERR(xbus, "dahdi_registration_mutex already taken\n"); return; } + if (!xbus_is_registered(xbus)) { + /* + * Ignore duplicate unregistrations + */ + XBUS_DBG(DEVICES, xbus, "Already unregistered to DAHDI\n"); + goto err; + } for (i = 0; i < MAX_XPDS; i++) { xpd_t *xpd = xpd_of(xbus, i); xpd_dahdi_preunregister(xpd); @@ -1054,6 +1061,7 @@ void xbus_unregister_dahdi_device(xbus_t *xbus) xpd_t *xpd = xpd_of(xbus, i); xpd_dahdi_postunregister(xpd); } +err: mutex_unlock(&dahdi_registration_mutex); }