Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3470622imu; Sun, 11 Nov 2018 15:51:30 -0800 (PST) X-Google-Smtp-Source: AJdET5dmTjaD26LjN1z3TV4s/SXWhA/qV2OtQwbH9i4qry/EkIjG3K45l6r/raAAiE4IpcO/kgDc X-Received: by 2002:a63:e001:: with SMTP id e1mr15589111pgh.39.1541980290508; Sun, 11 Nov 2018 15:51:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980290; cv=none; d=google.com; s=arc-20160816; b=zTWmD+2jsEnsHwYz0PRZahgQ4kpT9B0zI9gWm+9HEwA3USfHFfr4Nn+kVwkiNcxvsj bPVcQGo2qGEQNLWqpjb/zbzwnLQtzdROUPLyYi8KDMI0SusqQSIgQRW3kLHXoO2T9Tps vJfgoDtcK/5HwjdWTbyFLf0cQ7BichOyLaW1Ck8jxHD/9tj3EdDK3nAfEBw+tE8k0LDL hK/o5ZFBSMZjGBWcax5WU9uBpTLNAZwFUHZ6dgC/kXFJ2/lM6IyRu3//2xSJP6UdZy1x TKOYsHe3dL2NhupRJjLdzr954pL3OafNS9/NEPZEzTtmfiXIjR/ay8SflBMeGAhXv0F/ 0mSw== 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=ij8L+2RSylxmwFHC9XHo+cY7qiaLwxAmV1yB6w3Iaqs=; b=LrgGwhP4x/Fb6wiIu+DW7sef/MlcnxavL9q8i0SepYktJc3Us+2Gkk4ns1mcknHT/P xl5hSoLh8/GA6tV6HHKGHgAfOccUJQFxshoowF6m/+J9WUhoXxKzJ1kAul+ndh6NkKQi S5mWLqj2d7IMm9JI93k4+5f+qz+x2BDh6CqEh2DDKKpd6wKWH2FyJueJTd6bj0xmJ6Rv m+7ySx7wxy0sBiPsAlgkmiuCd7NYZLkXMMZbBMnzdPwUzx6Ux8Z39kqOKAQSPOLprxsx rgfhnFuyi3tzcJWFFTK6Ea2CIvfK2XBojCosQBYmYHv0H9OucjhkNOKM87cl+Qj8hwrA o3DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=orjUwSH2; 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 t13si14054487pgm.175.2018.11.11.15.51.15; Sun, 11 Nov 2018 15:51:30 -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=orjUwSH2; 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 S1733186AbeKLJkA (ORCPT + 99 others); Mon, 12 Nov 2018 04:40:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:37584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732993AbeKLISi (ORCPT ); Mon, 12 Nov 2018 03:18:38 -0500 Received: from localhost (unknown [206.108.79.134]) (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 42CF5224E0; Sun, 11 Nov 2018 22:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975322; bh=c+7ZtJSigCP1mYtL+p7+otcRV9QMJk8ODb+rn3USBg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=orjUwSH2KYQAnqlImC6IQaJ2bL+4mPhWC0DRDJ5sCUGkqk2lGhZeuO0V6mM35Gaso eHo4U5mpn/wLyqh/807GSDgOaLDZbePS93WTwdtvYZ0yMchkQMUZ4VwU91lYIADgrq HI0jVl7xWRhRSNPNjIZta/gDPPrJId2o8cp2SjQI= 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 Subject: [PATCH 4.19 288/361] power: supply: twl4030-charger: fix OF sibling-node lookup Date: Sun, 11 Nov 2018 14:20:35 -0800 Message-Id: <20181111221656.455964240@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold commit 9844fb2e351311210e6660a9a1c62d17424a6145 upstream. 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: Greg Kroah-Hartman --- drivers/power/supply/twl4030_charger.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/power/supply/twl4030_charger.c +++ b/drivers/power/supply/twl4030_charger.c @@ -996,12 +996,13 @@ static int twl4030_bci_probe(struct plat 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)