Skip to content

Commit 906bf7d

Browse files
jhovolddtor
authored andcommitted
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: 2e57d56 ("mfd: 88pm860x: Device tree support") Cc: stable <[email protected]> # 3.7 Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent dcaf12a commit 906bf7d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

drivers/input/touchscreen/88pm860x-ts.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static int pm860x_touch_dt_init(struct platform_device *pdev,
126126
int data, n, ret;
127127
if (!np)
128128
return -ENODEV;
129-
np = of_find_node_by_name(np, "touch");
129+
np = of_get_child_by_name(np, "touch");
130130
if (!np) {
131131
dev_err(&pdev->dev, "Can't find touch node\n");
132132
return -EINVAL;
@@ -144,13 +144,13 @@ static int pm860x_touch_dt_init(struct platform_device *pdev,
144144
if (data) {
145145
ret = pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data);
146146
if (ret < 0)
147-
return -EINVAL;
147+
goto err_put_node;
148148
}
149149
/* set tsi prebias time */
150150
if (!of_property_read_u32(np, "marvell,88pm860x-tsi-prebias", &data)) {
151151
ret = pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data);
152152
if (ret < 0)
153-
return -EINVAL;
153+
goto err_put_node;
154154
}
155155
/* set prebias & prechg time of pen detect */
156156
data = 0;
@@ -161,10 +161,18 @@ static int pm860x_touch_dt_init(struct platform_device *pdev,
161161
if (data) {
162162
ret = pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data);
163163
if (ret < 0)
164-
return -EINVAL;
164+
goto err_put_node;
165165
}
166166
of_property_read_u32(np, "marvell,88pm860x-resistor-X", res_x);
167+
168+
of_node_put(np);
169+
167170
return 0;
171+
172+
err_put_node:
173+
of_node_put(np);
174+
175+
return -EINVAL;
168176
}
169177
#else
170178
#define pm860x_touch_dt_init(x, y, z) (-1)

0 commit comments

Comments
 (0)