Received: by 10.223.185.116 with SMTP id b49csp6313286wrg; Wed, 28 Feb 2018 07:24:55 -0800 (PST) X-Google-Smtp-Source: AH8x224/bnusX5FwhRA2LShfDE3Vy+8xRi1bEsOaGtr0Brb6H3QTEYWJnRXT99+jFrqIXRXzD0qW X-Received: by 10.101.99.133 with SMTP id h5mr14110617pgv.381.1519831495479; Wed, 28 Feb 2018 07:24:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519831495; cv=none; d=google.com; s=arc-20160816; b=KnDFwKvPxhtRTCS88LKwZYVRxsfklzHuYq41nugd8FU58k8UWZkyDp47N8wgp0HIYx G2bXWMLtV8jrr0OhR0cOabzrkrUCRf0+Rqw7x8Y6jYcI4A2EutykoSpJWphwkJTqNqBf NP1+mHeIDwYPw7esKq3P8CXncgHzxyI32OP9J9bmS/+QT061RFqJnFvNVRFHGA3LK4mN i3fGSWQquCgaBVuKt56FRhSQVM3KZOxzntSD/tbTmRgl6unMONKMM6YRJxfkennR3RuY 63p/T0P0mmmNdNVq3538w8//eNSxzxh5LLIj6Lqw5n+lFgVu4BWkp8QFGii7JneTBHyx 9+OQ== 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=Ep/s7aNF+8QhN+yAfeqkgXJXwP1ruxV5QtQNlCPHoBw=; b=yJl8YIAQ2JMwkM/I6f5glgNSPuiDZjy+v5C2dFy2LDabtP3jMwGSyg18UD/Tz0Q8mm zRP4tBvypL8NWITaIEKJxtYRHhnDZ4VinEO5BIMSL+E3cFiqazV1FX2lfg2wsEBeSNIo 6++K9HTWXogvjX3chTYj2fCzaVTCwadt5aQS081qrDdZOppricXxqZrKp4PDXlsCtUU2 OrkVSNi71wxKuqKI17VrBD4kcdankMnNzTuH+NkTVFytKntWe2ApF+4t2+VXNNBpRCxg 5IjqDRjL/hRtK/LDUlWNsGnn5t7VW0EQPnO1LGh20BWdqXPwg19gkw2iFOEKmbyC9DtI vkhg== 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 d18si1372717pfl.307.2018.02.28.07.24.40; Wed, 28 Feb 2018 07:24:55 -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 S932751AbeB1PWv (ORCPT + 99 others); Wed, 28 Feb 2018 10:22:51 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:33223 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752683AbeB1PWd (ORCPT ); Wed, 28 Feb 2018 10:22:33 -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 1er3Yf-0006XT-BZ; Wed, 28 Feb 2018 15:22:17 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Ye-0008PI-07; Wed, 28 Feb 2018 15:22:16 +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" , "Peter Ujfalusi" , "Lee Jones" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 038/254] mfd: twl6040: 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 85e9b13cbb130a3209f21bd7933933399c389ffe 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 node was prematurely freed, while the child node was leaked. Note that the CONFIG_OF compile guard can be removed as of_get_child_by_name() provides a !CONFIG_OF implementation which always fails. Fixes: 37e13cecaa14 ("mfd: Add support for Device Tree to twl6040") Fixes: ca2cad6ae38e ("mfd: Fix twl6040 build failure") Signed-off-by: Johan Hovold Acked-by: Peter Ujfalusi Signed-off-by: Lee Jones Signed-off-by: Ben Hutchings --- drivers/mfd/twl6040.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/drivers/mfd/twl6040.c +++ b/drivers/mfd/twl6040.c @@ -97,12 +97,16 @@ static struct reg_default twl6040_patch[ }; -static bool twl6040_has_vibra(struct device_node *node) +static bool twl6040_has_vibra(struct device_node *parent) { -#ifdef CONFIG_OF - if (of_find_node_by_name(node, "vibra")) + struct device_node *node; + + node = of_get_child_by_name(parent, "vibra"); + if (node) { + of_node_put(node); return true; -#endif + } + return false; }