layerscape: add ls1088ardb device support
[openwrt/staging/lynxis/omap.git] / target / linux / layerscape / patches-4.4 / 7151-staging-fsl-mc-Fixed-bug-in-dprc_probe-error-path.patch
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
5 path
6
7 Destroy mc_io in error path in dprc_probe() only if the mc_io was
8 created in this function.
9
10 Signed-off-by: J. German Rivera <German.Rivera@freescale.com>
11 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 ---
13 drivers/staging/fsl-mc/bus/dprc-driver.c | 17 ++++++++++++++---
14 1 file changed, 14 insertions(+), 3 deletions(-)
15
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
19 size_t region_size;
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;
24
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
27 /*
28 * This is a child DPRC:
29 */
30 + if (WARN_ON(parent_dev->bus != &fsl_mc_bus_type))
31 + return -EINVAL;
32 +
33 if (WARN_ON(mc_dev->obj_desc.region_count == 0))
34 return -EINVAL;
35
36 @@ -427,6 +431,9 @@ static int dprc_probe(struct fsl_mc_devi
37 &mc_dev->mc_io);
38 if (error < 0)
39 return error;
40 +
41 + mc_io_created = true;
42 +
43 /*
44 * Inherit parent MSI domain:
45 */
46 @@ -457,7 +464,7 @@ static int dprc_probe(struct fsl_mc_devi
47 &mc_dev->mc_handle);
48 if (error < 0) {
49 dev_err(&mc_dev->dev, "dprc_open() failed: %d\n", error);
50 - goto error_cleanup_mc_io;
51 + goto error_cleanup_msi_domain;
52 }
53
54 mutex_init(&mc_bus->scan_mutex);
55 @@ -475,11 +482,15 @@ static int dprc_probe(struct fsl_mc_devi
56 error_cleanup_open:
57 (void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
58
59 -error_cleanup_mc_io:
60 +error_cleanup_msi_domain:
61 if (msi_domain_set)
62 dev_set_msi_domain(&mc_dev->dev, NULL);
63
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;
68 + }
69 +
70 return error;
71 }
72