Commit 8804f9fc authored by J. German Rivera's avatar J. German Rivera Committed by Greg Kroah-Hartman

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.
Signed-off-by: default avatarJ. German Rivera <German.Rivera@freescale.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 232ae8f2
...@@ -401,6 +401,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) ...@@ -401,6 +401,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
size_t region_size; size_t region_size;
struct device *parent_dev = mc_dev->dev.parent; struct device *parent_dev = mc_dev->dev.parent;
struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
bool mc_io_created = false;
bool msi_domain_set = false; bool msi_domain_set = false;
if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0)) 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) ...@@ -413,6 +414,9 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
/* /*
* This is a child DPRC: * 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)) if (WARN_ON(mc_dev->obj_desc.region_count == 0))
return -EINVAL; return -EINVAL;
...@@ -427,6 +431,9 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) ...@@ -427,6 +431,9 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
&mc_dev->mc_io); &mc_dev->mc_io);
if (error < 0) if (error < 0)
return error; return error;
mc_io_created = true;
/* /*
* Inherit parent MSI domain: * Inherit parent MSI domain:
*/ */
...@@ -457,7 +464,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) ...@@ -457,7 +464,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
&mc_dev->mc_handle); &mc_dev->mc_handle);
if (error < 0) { if (error < 0) {
dev_err(&mc_dev->dev, "dprc_open() failed: %d\n", error); dev_err(&mc_dev->dev, "dprc_open() failed: %d\n", error);
goto error_cleanup_mc_io; goto error_cleanup_msi_domain;
} }
mutex_init(&mc_bus->scan_mutex); mutex_init(&mc_bus->scan_mutex);
...@@ -475,11 +482,15 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) ...@@ -475,11 +482,15 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
error_cleanup_open: error_cleanup_open:
(void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle); (void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
error_cleanup_mc_io: error_cleanup_msi_domain:
if (msi_domain_set) if (msi_domain_set)
dev_set_msi_domain(&mc_dev->dev, NULL); dev_set_msi_domain(&mc_dev->dev, NULL);
fsl_destroy_mc_io(mc_dev->mc_io); if (mc_io_created) {
fsl_destroy_mc_io(mc_dev->mc_io);
mc_dev->mc_io = NULL;
}
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment