Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3314747imu; Sun, 11 Nov 2018 12:11:15 -0800 (PST) X-Google-Smtp-Source: AJdET5d2vQdpv3CTfbX0tlshFweapjFeq+jSfsLLzIbLJSILutQ6Quep77l+e0nhqzZ2usQMAXnX X-Received: by 2002:a62:25c2:: with SMTP id l185-v6mr17980397pfl.64.1541967075783; Sun, 11 Nov 2018 12:11:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541967075; cv=none; d=google.com; s=arc-20160816; b=nBkCT8+dV68jUs0ZMBOS6k3Jc26LdqHr5OfiY7BEXrrCn4mf5grHaXqD0oRtXllZkH V3u8whgTWZTtz+/9Y6J27UoCFE93ezWq5X3t0epM63nWOA2yi4XsNt+yusT4K9IZIdpw tLFFmLnMKulzlTm5MusaA+2uvETrpiqqBekVxu2sBliniSm5DGLc1rlLbjqDgbKFvlwZ 4E8Kce1UfJaOfbAMfb3PGsQzEK5QU5OP7xnqS3d6q3038KcJPRB/WdtBabZAUgN0q2Rw usKjvnhlREftBxu2WXghVNQOdgat0Nag8uFkqVETFnXCm2gxVfuz5Gxr9xKEYIKaPANB hpeQ== 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; bh=dAcO094cT/vps6pFuQDSNzdQlrJzARuidAT3KNzf77c=; b=bkO1iFPRIGv9bdyQATwo6Ui3qMc6dnj8XUno2HKd8gBY7XtwYdK+g5a6IQpn0X3Uug jX/du0g1EeVc5H0+zslxwHkVJFipHPcSBOKXEaJqdFQ7nZlT8OnxALtDMKZraA1vkWdL 6iC8J+8Gf+CIzP28XQbva3/D4lhJunbK1c+t3W6iGyCpB0moxh9sCgsXvV/SWyhat+hs ya1pwXgUtaycKU5jCm9NC+A1YAcPuTzm3xLe6dU1TpT6uIDoyj79WKkOiu5GnktS3Bbb PzpAmgVXqedZsxWQ2c9wl9MR+h0bJ1lxikvAEhem8kpy089t7em/JtlVu746I2uDh9Or HvHg== 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 t126-v6si16728509pfd.133.2018.11.11.12.11.00; Sun, 11 Nov 2018 12:11:15 -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 S1731412AbeKLF41 (ORCPT + 99 others); Mon, 12 Nov 2018 00:56:27 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:52052 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727449AbeKLF40 (ORCPT ); Mon, 12 Nov 2018 00:56:26 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvt2-0000lF-EX; Sun, 11 Nov 2018 19:59:12 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsR-0001XM-Sf; Sun, 11 Nov 2018 19:58:35 +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, "Lee Jones" , "Daniel Thompson" , "Johan Hovold" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 130/366] backlight: as3711_bl: Fix Device Tree node lookup In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 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.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold commit 4a9c8bb2aca5b5a2a15744333729745dd9903562 upstream. Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children. To make things worse, the parent mfd node was also prematurely freed. Fixes: 59eb2b5e57ea ("drivers/video/backlight/as3711_bl.c: add OF support") Signed-off-by: Johan Hovold Acked-by: Daniel Thompson Signed-off-by: Lee Jones Signed-off-by: Ben Hutchings --- drivers/video/backlight/as3711_bl.c | 33 ++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 10 deletions(-) --- a/drivers/video/backlight/as3711_bl.c +++ b/drivers/video/backlight/as3711_bl.c @@ -262,10 +262,10 @@ static int as3711_bl_register(struct pla static int as3711_backlight_parse_dt(struct device *dev) { struct as3711_bl_pdata *pdata = dev_get_platdata(dev); - struct device_node *bl = - of_find_node_by_name(dev->parent->of_node, "backlight"), *fb; + struct device_node *bl, *fb; int ret; + bl = of_get_child_by_name(dev->parent->of_node, "backlight"); if (!bl) { dev_dbg(dev, "backlight node not found\n"); return -ENODEV; @@ -279,7 +279,7 @@ static int as3711_backlight_parse_dt(str if (pdata->su1_max_uA <= 0) ret = -EINVAL; if (ret < 0) - return ret; + goto err_put_bl; } fb = of_parse_phandle(bl, "su2-dev", 0); @@ -292,7 +292,7 @@ static int as3711_backlight_parse_dt(str if (pdata->su2_max_uA <= 0) ret = -EINVAL; if (ret < 0) - return ret; + goto err_put_bl; if (of_find_property(bl, "su2-feedback-voltage", NULL)) { pdata->su2_feedback = AS3711_SU2_VOLTAGE; @@ -314,8 +314,10 @@ static int as3711_backlight_parse_dt(str pdata->su2_feedback = AS3711_SU2_CURR_AUTO; count++; } - if (count != 1) - return -EINVAL; + if (count != 1) { + ret = -EINVAL; + goto err_put_bl; + } count = 0; if (of_find_property(bl, "su2-fbprot-lx-sd4", NULL)) { @@ -334,8 +336,10 @@ static int as3711_backlight_parse_dt(str pdata->su2_fbprot = AS3711_SU2_GPIO4; count++; } - if (count != 1) - return -EINVAL; + if (count != 1) { + ret = -EINVAL; + goto err_put_bl; + } count = 0; if (of_find_property(bl, "su2-auto-curr1", NULL)) { @@ -355,11 +359,20 @@ static int as3711_backlight_parse_dt(str * At least one su2-auto-curr* must be specified iff * AS3711_SU2_CURR_AUTO is used */ - if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO)) - return -EINVAL; + if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO)) { + ret = -EINVAL; + goto err_put_bl; + } } + of_node_put(bl); + return 0; + +err_put_bl: + of_node_put(bl); + + return ret; } static int as3711_backlight_probe(struct platform_device *pdev)