i2c: muxes: fix leaked i2c adapter device node references
authorVladimir Zapolskiy <vz@mleia.com>
Wed, 26 Aug 2015 20:59:33 +0000 (23:59 +0300)
committerWolfram Sang <wsa@the-dreams.de>
Mon, 31 Aug 2015 20:40:34 +0000 (22:40 +0200)
Every call of of_parse_phandle() increments user count of found device
node, if OF_DYNAMIC is enabled.

The change fixes all similar addressed cases in drivers/i2c.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/muxes/i2c-arb-gpio-challenge.c
drivers/i2c/muxes/i2c-mux-gpio.c
drivers/i2c/muxes/i2c-mux-pinctrl.c
drivers/i2c/muxes/i2c-mux-reg.c

index 71aac0911bf75eed8fbfc7a55ab006af75e69354..402e3a6c671a11ac628d502b7a2833654cd66d68 100644 (file)
@@ -197,6 +197,7 @@ static int i2c_arbitrator_probe(struct platform_device *pdev)
                return -EINVAL;
        }
        arb->parent = of_get_i2c_adapter_by_node(parent_np);
+       of_node_put(parent_np);
        if (!arb->parent) {
                dev_err(dev, "Cannot find parent bus\n");
                return -EPROBE_DEFER;
index 70db99264339ef5c7d6ffa0df9c5b1fdda9dfeaf..b8e11c16d98c609dc653855d57ceb96067e2362f 100644 (file)
@@ -76,6 +76,7 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux,
                return -ENODEV;
        }
        adapter = of_find_i2c_adapter_by_node(adapter_np);
+       of_node_put(adapter_np);
        if (!adapter)
                return -EPROBE_DEFER;
 
index b48378c4b40d64bf707002f6140cc8bd2a0d6da2..b5a982ba88986d67f24802acfd2df6845691078d 100644 (file)
@@ -111,6 +111,7 @@ static int i2c_mux_pinctrl_parse_dt(struct i2c_mux_pinctrl *mux,
                return -ENODEV;
        }
        adapter = of_find_i2c_adapter_by_node(adapter_np);
+       of_node_put(adapter_np);
        if (!adapter) {
                dev_err(mux->dev, "Cannot find parent bus\n");
                return -EPROBE_DEFER;
index 86d41d36a78340690c8c4dc9dfe5665455be87ae..57ec57e0da529f99aea074053ce042ead0a5abba 100644 (file)
@@ -106,6 +106,7 @@ static int i2c_mux_reg_probe_dt(struct regmux *mux,
                return -ENODEV;
        }
        adapter = of_find_i2c_adapter_by_node(adapter_np);
+       of_node_put(adapter_np);
        if (!adapter)
                return -EPROBE_DEFER;