From aab9e51f3087d355e67329a698706e03e621fdd3 Mon Sep 17 00:00:00 2001 From: Oron Peled Date: Wed, 26 Oct 2011 19:06:32 +0000 Subject: [PATCH] xpp: make unregistration safer (idempotent) * Otherwise, a failed unit initialization (e.g: when init_card_?_?? fails) causes a panic Signed-off-by: Oron Peled git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10282 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/xpp/xbus-core.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c index 7fe0493..b2f7616 100644 --- a/drivers/dahdi/xpp/xbus-core.c +++ b/drivers/dahdi/xpp/xbus-core.c @@ -939,14 +939,16 @@ static void xbus_unregister_dahdi_device(xbus_t *xbus) xpd_t *xpd = xpd_of(xbus, i); xpd_dahdi_preunregister(xpd); } - dahdi_unregister_device(xbus->ddev); - XBUS_NOTICE(xbus, "%s: finished dahdi_unregister_device()\n", __func__); - kfree(xbus->ddev->devicetype); - xbus->ddev->devicetype = NULL; - xbus->ddev->location = NULL; - xbus->ddev->hardware_id = NULL; - dahdi_free_device(xbus->ddev); - xbus->ddev = NULL; + if (xbus->ddev) { + dahdi_unregister_device(xbus->ddev); + XBUS_NOTICE(xbus, "%s: finished dahdi_unregister_device()\n", __func__); + kfree(xbus->ddev->devicetype); + xbus->ddev->devicetype = NULL; + xbus->ddev->location = NULL; + xbus->ddev->hardware_id = NULL; + dahdi_free_device(xbus->ddev); + xbus->ddev = NULL; + } for(i = 0; i < MAX_XPDS; i++) { xpd_t *xpd = xpd_of(xbus, i); xpd_dahdi_postunregister(xpd);