Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2994465imm; Sun, 1 Jul 2018 09:56:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLyOfHht6E8GY4HLpMtC209gfhWX5ZcqpZv1Wxt7MtqQzibocdjTwTawe7sYchDUt1lPBug X-Received: by 2002:a17:902:1703:: with SMTP id i3-v6mr22184126pli.263.1530464186407; Sun, 01 Jul 2018 09:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530464186; cv=none; d=google.com; s=arc-20160816; b=gY+RDzZscG26kL9Asbk1ZT8c106RdF1LtLyzh5Byptqt73pJsQIUmHN+QU4cznk7Xa la3hs+xdOnJtmy9rWR4EgOMdj+1+1GXJFqkHxzptwMdozxNcDLkcUL1KD1LDY4wZorw6 OvlLHL15EOjX+iSYMds0L1EDAdYDr4IMYLfh3SfbWzn4BhRUe120ik4ZbyXG64wzGCC2 DHvc6M1GpwRj2YO51g9TkQTJ1ZGfaQArVlvHqNYoo3tEGzAUg0j7PFUPmAUH5h/87gJq /Dfvp6zKzOc9VwKVEmH0x80d3RfWr1j/XwvMbBcHykVWx/PbV09jd4VOpdXvixsOntg3 Ep5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=vFr8twWzZKgPH7skJVEoD6FgfFoQWzNOZywL3prxmZk=; b=bBPu4ueH2wY+hofGddIu3tocw1Xv7yEWIK6dSVzqNqWNHc3RwyaZEo5WFBoq99Wj9+ kdr5iyYK5RYBsPVKPFsHZp2cjw3DJDEHUjUIHoBL+H3c94/oYQBKM4+9wzqAnlU0Dut1 8Damf/jXYVy6d5Ax3Sb3MoynV2nKJfpUi4TFrmXd7iDFz8MBWiNgGArEMAsXhVXhnObo wr2mvIjtM3sfgisj1XOFVwAAji2f5JPG+2VrbZjqAdhV+WpzNKTzlvtygjexZZXYL683 64j4FhlIrw5AZ6FjoSjYhNrRWqowcncjq3s0y2M/n/3aU49hLlPiXYg/wi/JGNpGO6aX qMLA== 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 s184-v6si12618544pgb.161.2018.07.01.09.56.12; Sun, 01 Jul 2018 09:56:26 -0700 (PDT) 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 S934124AbeGAQpY (ORCPT + 99 others); Sun, 1 Jul 2018 12:45:24 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38194 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934076AbeGAQpR (ORCPT ); Sun, 1 Jul 2018 12:45:17 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C7019AA6; Sun, 1 Jul 2018 16:45:16 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Daniel Thompson , Lee Jones Subject: [PATCH 4.17 155/220] backlight: as3711_bl: Fix Device Tree node lookup Date: Sun, 1 Jul 2018 18:22:59 +0200 Message-Id: <20180701160914.759806210@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable 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. Cc: stable # 3.10 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: Greg Kroah-Hartman --- 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)