[PATCH 2/4] dspbridge: dev: fix dev_create_device()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



... when resources are not available.

Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
 drivers/dsp/bridge/pmgr/dev.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/dsp/bridge/pmgr/dev.c b/drivers/dsp/bridge/pmgr/dev.c
index c85a4fa..4ba8197 100644
--- a/drivers/dsp/bridge/pmgr/dev.c
+++ b/drivers/dsp/bridge/pmgr/dev.c
@@ -149,9 +149,11 @@ dsp_status dev_create_device(OUT struct dev_object **phDevObject,
 
 	status = drv_request_bridge_res_dsp((void *)&host_res);
 
-	if (DSP_FAILED(status))
+	if (DSP_FAILED(status)) {
 		dev_dbg(bridge, "%s: Failed to reserve bridge resources\n",
 			__func__);
+		goto leave;
+	}
 
 	/*  Get the WMD interface functions */
 	bridge_drv_entry(&drv_fxns, driver_file_name);
@@ -256,20 +258,20 @@ dsp_status dev_create_device(OUT struct dev_object **phDevObject,
 		else
 			INIT_LIST_HEAD(&dev_obj->proc_list->head);
 	}
+leave:
 	/*  If all went well, return a handle to the dev object;
 	 *  else, cleanup and return NULL in the OUT parameter. */
 	if (DSP_SUCCEEDED(status)) {
 		*phDevObject = dev_obj;
 	} else {
-		kfree(dev_obj->proc_list);
-
-		if (dev_obj && dev_obj->cod_mgr)
-			cod_delete(dev_obj->cod_mgr);
-
-		if (dev_obj && dev_obj->dmm_mgr)
-			dmm_destroy(dev_obj->dmm_mgr);
-
-		kfree(dev_obj);
+		if (dev_obj) {
+			kfree(dev_obj->proc_list);
+			if (dev_obj->cod_mgr)
+				cod_delete(dev_obj->cod_mgr);
+			if (dev_obj->dmm_mgr)
+				dmm_destroy(dev_obj->dmm_mgr);
+			kfree(dev_obj);
+		}
 
 		*phDevObject = NULL;
 	}
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux