Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2529289imu; Thu, 29 Nov 2018 06:27:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/VxlZO/YF4Toq5qk1+9SNu2xta7vda2YIO7zVAhpA0nK4KZpdrbzffmBHnNmL0Sf7yQiiJc X-Received: by 2002:a17:902:2bc5:: with SMTP id l63-v6mr1674001plb.241.1543501668564; Thu, 29 Nov 2018 06:27:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501668; cv=none; d=google.com; s=arc-20160816; b=0jFWkLcR9PCuv2XtcrChGUk95iy1+XGuhM7zVZpGid7K9ik6d5J4i3KLPj8LhubBjW TNgTmijlMoFIM4Cd0eXtY1lvn7BBNyMIG5Y+RVLYXn5Dv+5ojUsUni4HeWqtWZgA1O6H n8MeH0gqCmt8jgD/xrqx3VZ65ZK59HrKVaiEywuKGpP0e5bM5Cs9AnKBVa2RzJ6s7fyd tQCv/TlCzbAdmlcNT2qLhNIJKaPhii4QQ95cZeZB1777lhJz5KAKRXxVLshNbK1fkb1Q zi9/kJAtTNN4l6ZjfnwPRxEGuNXFiJe6o5WVQkaWKy9wUPqO/VuIZA1GzZbfXdmTwlHy BGmA== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bKIbKgC2VJ2aZu3Czfor1DaVPvPuuzmYrK50CHT7v7M=; b=NeDIuMBm8P/rcWp166g1alyHdSx7ayYycWn3xQ5rFlELqKdWyOEup1fP8qAe2+PO6u G6J9lUrGW0nAc6Wn278hO03nx3tEmVIW+CWQs6VGGlEl/17kR76EeaHyID5fO7O0G9+J aLsmnS9IC7T0efnBW6jRhqJsyJKknZUFq3XWxCilSkOZ99aRtoiiFqQtUJ2p82D/Ge/y 4yMyMOp/o98nCXTHGacpuqSwfi5gMSrFmcXOExPj+CnVdJrKj7F2ElxXPpXmIOFcqUzG Q47SL6Ue7JJB5zo8M9UpTRl/qKAxyRE+3v/O4C1Uy7/Ufxga/6KJ3vlRqncc/GOcXM3L sDoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="AiwDK/1Q"; 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 v141si2453293pfc.260.2018.11.29.06.27.33; Thu, 29 Nov 2018 06:27:48 -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=@kernel.org header.s=default header.b="AiwDK/1Q"; 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 S2387514AbeK3Bc0 (ORCPT + 99 others); Thu, 29 Nov 2018 20:32:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:60604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732456AbeK3BcZ (ORCPT ); Thu, 29 Nov 2018 20:32:25 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2262F2145D; Thu, 29 Nov 2018 14:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501613; bh=I+MgIhWl17b+Yy5SPJJ2d/DNeHQW9fGpBx5vJJFW+PA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AiwDK/1QQJjxMQSuMOgE5iQTLpkAi4LoP3XMCnwBR3cX9LT8svrJkT9cK2lLF7O+K /0FetONIyiZxs9HE2Wul28wghgbdEZIzkhnF/RV9TzZai3wCC4HtkBj+IOR6PztG4w r2jrQp0W9o2r6sLLWNQW5ABDN4ynR8AmdLO/ZGzQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, NeilBrown , Felipe Balbi , Sebastian Reichel , Johan Hovold , Rob Herring , Sasha Levin Subject: [PATCH 4.14 069/100] power: supply: twl4030-charger: fix OF sibling-node lookup Date: Thu, 29 Nov 2018 15:12:39 +0100 Message-Id: <20181129140104.857998365@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140058.768942700@linuxfoundation.org> References: <20181129140058.768942700@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 9844fb2e351311210e6660a9a1c62d17424a6145 ] Use the new of_get_compatible_child() helper to lookup the usb sibling node instead of using of_find_compatible_node(), which searches the entire tree from a given start node and thus can return an unrelated (non-sibling) node. This also addresses a potential use-after-free (e.g. after probe deferral) as the tree-wide helper drops a reference to its first argument (i.e. the parent device node). While at it, also fix the related phy-node reference leak. Fixes: f5e4edb8c888 ("power: twl4030_charger: find associated phy by more reliable means.") Cc: stable # 4.2 Cc: NeilBrown Cc: Felipe Balbi Cc: Sebastian Reichel Reviewed-by: Sebastian Reichel Signed-off-by: Johan Hovold Signed-off-by: Rob Herring Signed-off-by: Sasha Levin --- drivers/power/supply/twl4030_charger.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c index a5915f498eea..0cc12bfe7b02 100644 --- a/drivers/power/supply/twl4030_charger.c +++ b/drivers/power/supply/twl4030_charger.c @@ -996,12 +996,13 @@ static int twl4030_bci_probe(struct platform_device *pdev) if (bci->dev->of_node) { struct device_node *phynode; - phynode = of_find_compatible_node(bci->dev->of_node->parent, - NULL, "ti,twl4030-usb"); + phynode = of_get_compatible_child(bci->dev->of_node->parent, + "ti,twl4030-usb"); if (phynode) { bci->usb_nb.notifier_call = twl4030_bci_usb_ncb; bci->transceiver = devm_usb_get_phy_by_node( bci->dev, phynode, &bci->usb_nb); + of_node_put(phynode); if (IS_ERR(bci->transceiver)) { ret = PTR_ERR(bci->transceiver); if (ret == -EPROBE_DEFER) -- 2.17.1