Received: by 10.223.185.116 with SMTP id b49csp6400754wrg; Wed, 28 Feb 2018 08:48:09 -0800 (PST) X-Google-Smtp-Source: AH8x225SHl4PUwZde/UhZ4dCIujrvu/yI+Q4X3OeH5z/lnxAqR8ky5cb+HAuira2K7xryEd5xNms X-Received: by 10.99.154.73 with SMTP id e9mr14370111pgo.26.1519836489672; Wed, 28 Feb 2018 08:48:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519836489; cv=none; d=google.com; s=arc-20160816; b=nZUiR2PJWEgkrFWwEz1aun/XdbtC6yStFDDSj9Oc86OFOmL+evGq6EEFxHIjkFOidn g4bLCmVadatY5a/kjHsGD/Jg6cN6sD2Yzx/VuKtjSMUVOP9mUGffhXQj1Gdqstf19dF2 788EjTyVoGOlx9CN7KBMwEuNq55VsQNUYaJgANEd10XY2IeuKHOyqOaRuq7w/uFBH9q3 AHrfhQSm2mgGikY4jCxovMnGrNV8dwR2BSDjTAlj3ow8B9UyixNeeZ8qRQfQmDSXA+RS cTb+IFhvnpUA3Sm4c2iQyVOL3JQAwhTyjOrHtznVdmjvDK/SvG84jqsJMptzayMeS4HE G7bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=U3IHPtSvwhz9pHMfL3dWsmAvl+9GVQZtBP0NzadBSoY=; b=RX6iS8Kxd7hS+djzTib0XErIEGVGKGV08OroF1nicy02H12eSf+owDVFDZspOtrBJN Q7EOc1tA3J8GCMP9Gy9rziYf/D7w5TZqQwf3KtBebQQ5PVZlerueYAu2CUc9x80Yu6MU dqUTAYuY8aVC1tTboj4L/+gRNspD+vLc6FvqHWhgjlHEfxX+2uxSdc6LB5jh5xg1pJE+ yo0uB3ljDmV/oFbXaZGMwoD+JklV1f5VyJ/x3WAS2Tpjae1UTuLM4C5RYFtqY1kC8ToK mR7w2iAX44En2YMX6V6cx2sCIClORHB1oZcHnKyoFDsx5p/BFXUVSsD14zlnSlREbqbh Gcgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3-v6si1522516pld.180.2018.02.28.08.47.55; Wed, 28 Feb 2018 08:48:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934121AbeB1P7O (ORCPT + 99 others); Wed, 28 Feb 2018 10:59:14 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:34608 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932418AbeB1P7M (ORCPT ); Wed, 28 Feb 2018 10:59:12 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yq-0006Xg-M0; Wed, 28 Feb 2018 15:22:28 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Yj-0000Ee-96; Wed, 28 Feb 2018 15:22:21 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Johan Hovold" , "Dmitry Torokhov" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 189/254] Input: 88pm860x-ts - fix child-node lookup In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold commit 906bf7daa0618d0ef39f4872ca42218c29a3631f upstream. 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") Signed-off-by: Johan Hovold Signed-off-by: Dmitry Torokhov Signed-off-by: Ben Hutchings --- drivers/input/touchscreen/88pm860x-ts.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) --- 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 p 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 p 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 p 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)