[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1445874561-14761-9-git-send-email-German.Rivera@freescale.com>
Date: Mon, 26 Oct 2015 10:49:19 -0500
From: "J. German Rivera" <German.Rivera@...escale.com>
To: <gregkh@...uxfoundation.org>, <arnd@...db.de>,
<devel@...verdev.osuosl.org>, <linux-kernel@...r.kernel.org>
CC: <stuart.yoder@...escale.com>, <itai.katz@...escale.com>,
<lijun.pan@...escale.com>, <leoli@...escale.com>,
<scottwood@...escale.com>, <agraf@...e.de>,
<bhamciu1@...escale.com>, <R89243@...escale.com>,
<bhupesh.sharma@...escale.com>, <nir.erez@...escale.com>,
<richard.schmitt@...escale.com>, <dan.carpenter@...cle.com>,
<marc.zyngier@....com>, <jiang.liu@...ux.intel.com>,
"J. German Rivera" <German.Rivera@...escale.com>
Subject: [PATCH 08/10] staging: fsl-mc: Fixed bug in dprc_probe() error path
Destroy mc_io in error path in dprc_probe() only if the mc_io was
created in this function. Minor refactoring in error labels.
Signed-off-by: J. German Rivera <German.Rivera@...escale.com>
---
drivers/staging/fsl-mc/bus/dprc-driver.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 455379d..3eeafaa 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -401,6 +401,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
size_t region_size;
struct device *parent_dev = mc_dev->dev.parent;
struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
+ bool mc_io_created = false;
bool msi_domain_set = false;
if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0))
@@ -413,6 +414,9 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
/*
* This is a child DPRC:
*/
+ if (WARN_ON(parent_dev->bus != &fsl_mc_bus_type))
+ return -EINVAL;
+
if (WARN_ON(mc_dev->obj_desc.region_count == 0))
return -EINVAL;
@@ -427,6 +431,9 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
&mc_dev->mc_io);
if (error < 0)
return error;
+
+ mc_io_created = true;
+
/*
* Inherit parent MSI domain:
*/
@@ -457,7 +464,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
&mc_dev->mc_handle);
if (error < 0) {
dev_err(&mc_dev->dev, "dprc_open() failed: %d\n", error);
- goto error_cleanup_mc_io;
+ goto dprc_open_error;
}
mutex_init(&mc_bus->scan_mutex);
@@ -467,19 +474,23 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
*/
error = dprc_scan_container(mc_dev);
if (error < 0)
- goto error_cleanup_open;
+ goto dprc_scan_container_error;
+
dev_info(&mc_dev->dev, "DPRC device bound to driver");
return 0;
-error_cleanup_open:
+dprc_scan_container_error:
(void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
+dprc_open_error:
+ if (mc_io_created) {
+ fsl_destroy_mc_io(mc_dev->mc_io);
+ mc_dev->mc_io = NULL;
+ }
-error_cleanup_mc_io:
if (msi_domain_set)
dev_set_msi_domain(&mc_dev->dev, NULL);
- fsl_destroy_mc_io(mc_dev->mc_io);
return error;
}
--
2.3.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists