diff options
author | Johan Hovold <johan@kernel.org> | 2018-01-08 20:20:18 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2018-01-08 20:40:59 -0500 |
commit | 906bf7daa0618d0ef39f4872ca42218c29a3631f (patch) | |
tree | 1b8188fbdef4fca4cf3e64ad1980ab9b3af4137e | |
parent | dcaf12a8b0bbdbfcfa2be8dff2c4948d9844b4ad (diff) |
Input: 88pm860x-ts - fix child-node lookup
Fix child node-lookup during probe, which ended up searching the whole
device tree depth-first starting at parent rather than just matching on
its children.
To make things worse, the parent node was prematurely freed, while the
child node was leaked.
Fixes: 2e57d56747e6 ("mfd: 88pm860x: Device tree support")
Cc: stable <stable@vger.kernel.org> # 3.7
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/touchscreen/88pm860x-ts.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/input/touchscreen/88pm860x-ts.c b/drivers/input/touchscreen/88pm860x-ts.c index 7ed828a51f4c..3486d9403805 100644 --- a/drivers/input/touchscreen/88pm860x-ts.c +++ b/drivers/input/touchscreen/88pm860x-ts.c | |||
@@ -126,7 +126,7 @@ static int pm860x_touch_dt_init(struct platform_device *pdev, | |||
126 | int data, n, ret; | 126 | int data, n, ret; |
127 | if (!np) | 127 | if (!np) |
128 | return -ENODEV; | 128 | return -ENODEV; |
129 | np = of_find_node_by_name(np, "touch"); | 129 | np = of_get_child_by_name(np, "touch"); |
130 | if (!np) { | 130 | if (!np) { |
131 | dev_err(&pdev->dev, "Can't find touch node\n"); | 131 | dev_err(&pdev->dev, "Can't find touch node\n"); |
132 | return -EINVAL; | 132 | return -EINVAL; |
@@ -144,13 +144,13 @@ static int pm860x_touch_dt_init(struct platform_device *pdev, | |||
144 | if (data) { | 144 | if (data) { |
145 | ret = pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data); | 145 | ret = pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data); |
146 | if (ret < 0) | 146 | if (ret < 0) |
147 | return -EINVAL; | 147 | goto err_put_node; |
148 | } | 148 | } |
149 | /* set tsi prebias time */ | 149 | /* set tsi prebias time */ |
150 | if (!of_property_read_u32(np, "marvell,88pm860x-tsi-prebias", &data)) { | 150 | if (!of_property_read_u32(np, "marvell,88pm860x-tsi-prebias", &data)) { |
151 | ret = pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data); | 151 | ret = pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data); |
152 | if (ret < 0) | 152 | if (ret < 0) |
153 | return -EINVAL; | 153 | goto err_put_node; |
154 | } | 154 | } |
155 | /* set prebias & prechg time of pen detect */ | 155 | /* set prebias & prechg time of pen detect */ |
156 | data = 0; | 156 | data = 0; |
@@ -161,10 +161,18 @@ static int pm860x_touch_dt_init(struct platform_device *pdev, | |||
161 | if (data) { | 161 | if (data) { |
162 | ret = pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data); | 162 | ret = pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data); |
163 | if (ret < 0) | 163 | if (ret < 0) |
164 | return -EINVAL; | 164 | goto err_put_node; |
165 | } | 165 | } |
166 | of_property_read_u32(np, "marvell,88pm860x-resistor-X", res_x); | 166 | of_property_read_u32(np, "marvell,88pm860x-resistor-X", res_x); |
167 | |||
168 | of_node_put(np); | ||
169 | |||
167 | return 0; | 170 | return 0; |
171 | |||
172 | err_put_node: | ||
173 | of_node_put(np); | ||
174 | |||
175 | return -EINVAL; | ||
168 | } | 176 | } |
169 | #else | 177 | #else |
170 | #define pm860x_touch_dt_init(x, y, z) (-1) | 178 | #define pm860x_touch_dt_init(x, y, z) (-1) |