1 From 22aa842ae501ea8724afd45fcb0d7b17a67cb950 Mon Sep 17 00:00:00 2001
2 From: "J. German Rivera" <German.Rivera@freescale.com>
3 Date: Wed, 6 Jan 2016 16:03:27 -0600
4 Subject: [PATCH 151/226] staging: fsl-mc: Fixed bug in dprc_probe() error
7 Destroy mc_io in error path in dprc_probe() only if the mc_io was
8 created in this function.
10 Signed-off-by: J. German Rivera <German.Rivera@freescale.com>
11 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
13 drivers/staging/fsl-mc/bus/dprc-driver.c | 17 ++++++++++++++---
14 1 file changed, 14 insertions(+), 3 deletions(-)
16 --- a/drivers/staging/fsl-mc/bus/dprc-driver.c
17 +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
18 @@ -401,6 +401,7 @@ static int dprc_probe(struct fsl_mc_devi
20 struct device *parent_dev = mc_dev->dev.parent;
21 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
22 + bool mc_io_created = false;
23 bool msi_domain_set = false;
25 if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0))
26 @@ -413,6 +414,9 @@ static int dprc_probe(struct fsl_mc_devi
28 * This is a child DPRC:
30 + if (WARN_ON(parent_dev->bus != &fsl_mc_bus_type))
33 if (WARN_ON(mc_dev->obj_desc.region_count == 0))
36 @@ -427,6 +431,9 @@ static int dprc_probe(struct fsl_mc_devi
41 + mc_io_created = true;
44 * Inherit parent MSI domain:
46 @@ -457,7 +464,7 @@ static int dprc_probe(struct fsl_mc_devi
49 dev_err(&mc_dev->dev, "dprc_open() failed: %d\n", error);
50 - goto error_cleanup_mc_io;
51 + goto error_cleanup_msi_domain;
54 mutex_init(&mc_bus->scan_mutex);
55 @@ -475,11 +482,15 @@ static int dprc_probe(struct fsl_mc_devi
57 (void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
60 +error_cleanup_msi_domain:
62 dev_set_msi_domain(&mc_dev->dev, NULL);
64 - fsl_destroy_mc_io(mc_dev->mc_io);
65 + if (mc_io_created) {
66 + fsl_destroy_mc_io(mc_dev->mc_io);
67 + mc_dev->mc_io = NULL;