From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756315AbeAIBgG (ORCPT + 1 other); Mon, 8 Jan 2018 20:36:06 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:44476 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752033AbeAIBgA (ORCPT ); Mon, 8 Jan 2018 20:36:00 -0500 X-Google-Smtp-Source: ACJfBovMVSW7U1IDPHIqM8+BHz15YFsyorwIChURKCt16s7MDh0rjaj1GOu4YKjDW9lNv1AWaeoqjA== Date: Mon, 8 Jan 2018 17:35:57 -0800 From: Dmitry Torokhov To: Johan Hovold Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stable , Haojian Zhuang Subject: Re: [PATCH 3/3] Input: 88pm860x-ts: fix child-node lookup Message-ID: <20180109013557.geqzv3irrqtha3nt@dtor-ws> References: <20171111154339.16875-1-johan@kernel.org> <20171111154339.16875-3-johan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171111154339.16875-3-johan@kernel.org> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Sat, Nov 11, 2017 at 04:43:39PM +0100, Johan Hovold wrote: > 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 # 3.7 > Cc: Haojian Zhuang > Signed-off-by: Johan Hovold Applied, thank you. > --- > drivers/input/touchscreen/88pm860x-ts.c | 16 ++++++++++++---- > 1 file 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, > int data, n, ret; > if (!np) > return -ENODEV; > - np = of_find_node_by_name(np, "touch"); > + np = of_get_child_by_name(np, "touch"); > if (!np) { > dev_err(&pdev->dev, "Can't find touch node\n"); > return -EINVAL; > @@ -144,13 +144,13 @@ static int pm860x_touch_dt_init(struct platform_device *pdev, > if (data) { > ret = pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data); > if (ret < 0) > - return -EINVAL; > + goto err_put_node; > } > /* set tsi prebias time */ > if (!of_property_read_u32(np, "marvell,88pm860x-tsi-prebias", &data)) { > ret = pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data); > if (ret < 0) > - return -EINVAL; > + goto err_put_node; > } > /* set prebias & prechg time of pen detect */ > data = 0; > @@ -161,10 +161,18 @@ static int pm860x_touch_dt_init(struct platform_device *pdev, > if (data) { > ret = pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data); > if (ret < 0) > - return -EINVAL; > + goto err_put_node; > } > of_property_read_u32(np, "marvell,88pm860x-resistor-X", res_x); > + > + of_node_put(np); > + > return 0; > + > +err_put_node: > + of_node_put(np); > + > + return -EINVAL; > } > #else > #define pm860x_touch_dt_init(x, y, z) (-1) > -- > 2.15.0 > -- Dmitry