From patchwork Mon Nov 20 10:45:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 10067749 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4A7576022E for ; Tue, 21 Nov 2017 08:39:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38F7328F43 for ; Tue, 21 Nov 2017 08:39:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D8F328F80; Tue, 21 Nov 2017 08:39:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A3EAE28F43 for ; Tue, 21 Nov 2017 08:39:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B375A6E36F; Tue, 21 Nov 2017 08:39:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com [IPv6:2a00:1450:4010:c07::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 65BB76E169 for ; Mon, 20 Nov 2017 10:45:56 +0000 (UTC) Received: by mail-lf0-x242.google.com with SMTP id w23so9504756lfd.11 for ; Mon, 20 Nov 2017 02:45:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=uLBEhamrBUII5D5q30lhplYRvI6tWB5A3toQegSylJ8=; b=sY0w5X3F6tyUCFucxN5DrzS/hGYxO1zqdliW+y2f6Uh66pynhYemIvGq6mfMLgpxoE uO9s+/M3vwsM6QALbt1TkTOLZ+YCDdIqGGcp3Y4laa2LtibhEUeR3rXqjZqQndbRgk9B F9V0qB0T4wAWatLEhalPaSp2uCK0mGM+TkcH2WObbymfnnaqhSVcnFYxF/k4GWqheRKN tXeP2FziW3JB45DbSF9W+MIQ/VSv5HcBsjqAh4NqADsQOZAumqyVM0BFGfomSMdiGDCb dgwtxLk8NPAqykiONL6YLd073SSy/l5hqb/inhg6RzhbDrKZaOAylSDhUSbbFpZgFH4R JsGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=uLBEhamrBUII5D5q30lhplYRvI6tWB5A3toQegSylJ8=; b=XnWGsJyPrTdjyCmACyBUYmbVmjqlZdA+XEUXhuw7hv00jxjgPaaN/GfhZLMgs05f1Z K0dG8KhXAP6T6N1hb1fwynCQ50TpmZqo/IoF6D5/tHzSrmlSXZI5PEScXQ5/EEtiIorQ tGzGf1ORKBq/hUs89cxTdTA0hL4MFdqYsK2CNqndpMafL0z4UdIxsYy5ZOUgvQKFKIIt ikgidxQ9koIxPfZBPgj4YlkhKqvvVe6Lspp3HQ8sYYk2KKh9HOFQo2N02OQfZ/EiPiss 66MRRB2S9Sjq39R0jOZcVCUMUaJT1tUVvDFVqHjI+ZuFqwnRzhF/Ab5WpT1tJYF6/G+K yzzw== X-Gm-Message-State: AJaThX5jBHCp+4DXxG1vgTVnG77UtFPGrTE8gIGU3MP8MfeXIiO1deug OsJfaKP2bffwO4JniLXq09U= X-Google-Smtp-Source: AGs4zMZzE18ZGM4q9LQPlqobsgphG/1Wi8BuSX80IjSGg3gc88RKIk77SeJ+++Fv/0nHgBD/L5vvMg== X-Received: by 10.25.152.82 with SMTP id a79mr3207728lfe.237.1511174754675; Mon, 20 Nov 2017 02:45:54 -0800 (PST) Received: from xi.terra (c-c0bae655.07-184-6d6c6d4.cust.bredbandsbolaget.se. [85.230.186.192]) by smtp.gmail.com with ESMTPSA id r101sm1891978lfi.17.2017.11.20.02.45.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2017 02:45:53 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1eGjaJ-0000hR-Vp; Mon, 20 Nov 2017 11:45:52 +0100 From: Johan Hovold To: Lee Jones Subject: [PATCH v2 1/4] backlight: as3711_bl: fix device-tree node lookup Date: Mon, 20 Nov 2017 11:45:44 +0100 Message-Id: <20171120104547.2639-2-johan@kernel.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171120104547.2639-1-johan@kernel.org> References: <20171120104547.2639-1-johan@kernel.org> X-Mailman-Approved-At: Tue, 21 Nov 2017 08:39:20 +0000 Cc: Daniel Thompson , Bartlomiej Zolnierkiewicz , Jingoo Han , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Johan Hovold , stable , linux-fbdev@vger.kernel.org, Guennadi Liakhovetski X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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") Cc: stable # 3.10 Cc: Guennadi Liakhovetski Signed-off-by: Johan Hovold --- drivers/video/backlight/as3711_bl.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/video/backlight/as3711_bl.c b/drivers/video/backlight/as3711_bl.c index 734a9158946b..e55304d5cf07 100644 --- a/drivers/video/backlight/as3711_bl.c +++ b/drivers/video/backlight/as3711_bl.c @@ -262,10 +262,10 @@ static int as3711_bl_register(struct platform_device *pdev, 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(struct device *dev) 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(struct device *dev) 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(struct device *dev) 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(struct device *dev) 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(struct device *dev) * 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)