Received: by 10.223.164.202 with SMTP id h10csp271927wrb; Mon, 13 Nov 2017 06:17:11 -0800 (PST) X-Google-Smtp-Source: AGs4zMYqMDAAtMAtOQfsP4/pwHclHvdDTzhM8R8ZNV4yceyxbvD8TzxOdf5mo1pTj/BcolIdMQI4 X-Received: by 10.84.232.202 with SMTP id x10mr8954292plm.101.1510582631101; Mon, 13 Nov 2017 06:17:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510582631; cv=none; d=google.com; s=arc-20160816; b=mxMxcPDDcQOQVWhPaSzE/8v/R/eT9gDZPp/uFnIakarmZ/NMA0LSUNcKL36Ll6yUPU 5iMdxqgbYvvCNSCGQTm2cacveoPmAroWIbFbjWL8awkKNmvzT5MNqq76MGcgzA2QUkPl Uo2TWbSCrY+BzQaazW4q/sYGfJtUq26oD83T220CyNaf3I3ysi7FqBc++XHm5GF6f5f4 5lUBKDaSVa8RJ69IFJL72MMaYGPFMCi5QWen6IKETl8Uch0VDAP8Jr+s1CMveG0EaiYl QlKLRLe7zJSOESvVPqyri4ym5nHVi4zlioAaEdp6pjH6XXAMRh5Tm8vsm5YPikYaE7RG hxJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=WlljkHqNigd09iVtS6AEiTsBlr8v+VMqFadTpvwbLe0=; b=fhyk9JYi1dJnzJL7IHQVcOut3WbtSvXqq8My/oTkgCiE+wf46sMeb3dmKFRHMyMOsj 0JXsKsAhFUTdMSU/fB17YzzdkIgVBlUSuVB15lbtHDG+3hnkWA2Gvhn7I/0rJLw45YHt 0YmdPzdra9ELN6vh5XZGNH688aj389gTHRXWasabwy+DwN+zzGopkok1qQXeBUWQbEa9 iFR+Ad53VF2DbS4WOaknBItAq3xW6xFX4AF/ZXF9L4JsNgfaZP93yT6kzjeJcXRxZXFx Wnp1yOwqNTL0kO1IFcCjVYSuIkM7ll0CsR3mr27v84Q9Cvp3d490JPutJJ0ZsST/b0Zo 45Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NUSxMR/u; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i69si7633594pfd.147.2017.11.13.06.16.57; Mon, 13 Nov 2017 06:17:11 -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; dkim=pass header.i=@linaro.org header.s=google header.b=NUSxMR/u; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752719AbdKMOQR (ORCPT + 92 others); Mon, 13 Nov 2017 09:16:17 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:55802 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752263AbdKMOQO (ORCPT ); Mon, 13 Nov 2017 09:16:14 -0500 Received: by mail-wm0-f68.google.com with SMTP id 9so9984417wme.4 for ; Mon, 13 Nov 2017 06:16:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=WlljkHqNigd09iVtS6AEiTsBlr8v+VMqFadTpvwbLe0=; b=NUSxMR/uuC5wPGbmSikX6XhFVN1FlSurkRDrfA3AjxnjiKCex99fTJdj7YsBRY/m6M lji8wgnNx1chfGr1IrhmlIWaNsO8TavWL9TIJPcHbHbLsxKL4HjIChOoRXMEYMm6Gap3 yNYxK96BjVMWAdp9umUFij8gNpQfQN9KEEo5A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=WlljkHqNigd09iVtS6AEiTsBlr8v+VMqFadTpvwbLe0=; b=b3uGY7hsJPVHQmC4Nf6zaYxRaY5M4Qbd/r1hreqQyvvydDhTxbBRdwMu4KTCJ6QMK+ wuetT60Y6Jx66yZsj7oJ37IPkY+MJH0bYU/McRl0rACkScv4HXD4x1CM6A+PPYRu4ze5 K6XATIYh6OPInK3B6MVDrgwBHGVImZlS4AOmJyQc0XiTslFCWO6R4E6ChOwfT6uRximL Kvalqhj5ioIeDtfllKpgUgzwnlwC1OYY31rGDCmL62okpK0lKCAW9E4FG+gunUJ+Q+1n qqb58c43sJl20EncM9i0JMpYp9WEenLEQeEQDq2DCcLtv8jdtW1hyppTX/OLDMPfB/sK ibHw== X-Gm-Message-State: AJaThX4IeNk2+Re6FYKVIgh+B738L80KZkEG25wccUYFxM1NIromvdt6 7ks4T8ipFNMrKP/kkbyhexYWew== X-Received: by 10.80.136.124 with SMTP id c57mr12913890edc.59.1510582573294; Mon, 13 Nov 2017 06:16:13 -0800 (PST) Received: from [192.168.1.111] (cpc87211-aztw31-2-0-cust196.18-1.cable.virginm.net. [82.46.60.197]) by smtp.gmail.com with ESMTPSA id h2sm13893410edc.89.2017.11.13.06.16.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Nov 2017 06:16:12 -0800 (PST) Subject: Re: [PATCH 1/3] backlight: as3711_bl: fix device-tree node lookup To: Johan Hovold , Lee Jones Cc: Jingoo Han , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable , Guennadi Liakhovetski References: <20171113102049.9342-1-johan@kernel.org> From: Daniel Thompson Message-ID: <94c3debe-17f6-9151-eefe-129f2bd1cfd4@linaro.org> Date: Mon, 13 Nov 2017 14:16:09 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171113102049.9342-1-johan@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/11/17 10:20, Johan Hovold wrote: > 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. > > Note that the nodes returned from the two calls to of_parse_phandle() > are also leaking, but fixing that is a bit more involved as pointers to > node fields are being stored for later use. Is using a devm_kstrdup() to remember the full_name sufficient so get each of the FIXMEs cleaned up as well? Daniel. > 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 | 35 +++++++++++++++++++++++++---------- > 1 file changed, 25 insertions(+), 10 deletions(-) > > diff --git a/drivers/video/backlight/as3711_bl.c b/drivers/video/backlight/as3711_bl.c > index 734a9158946b..21ce56053c88 100644 > --- a/drivers/video/backlight/as3711_bl.c > +++ b/drivers/video/backlight/as3711_bl.c > @@ -262,15 +262,16 @@ 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; > } > > + /* FIXME: need to drop reference to returned node */ > fb = of_parse_phandle(bl, "su1-dev", 0); > if (fb) { > pdata->su1_fb = fb->full_name; > @@ -279,9 +280,10 @@ 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; > } > > + /* FIXME: need to drop reference to returned node */ > fb = of_parse_phandle(bl, "su2-dev", 0); > if (fb) { > int count = 0; > @@ -292,7 +294,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 +316,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 +338,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 +361,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) > From 1583945945590122535@xxx Mon Nov 13 10:22:46 +0000 2017 X-GM-THRID: 1583945945590122535 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread