From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751322AbdKKPbt (ORCPT ); Sat, 11 Nov 2017 10:31:49 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:48263 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750818AbdKKPbq (ORCPT ); Sat, 11 Nov 2017 10:31:46 -0500 X-Google-Smtp-Source: AGs4zMZUtFQCLGjExUFL5MZmvmLWY7dpDkqVNuusM82ZjWt8XVS+S0dGVi7plXwsoz3mmTsQJ2vZ8Q== From: Johan Hovold To: Heikki Krogerus Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Rob Clark , Peter Robinson , Johan Hovold , stable Subject: [PATCH] USB: ulpi: fix bus-node lookup Date: Sat, 11 Nov 2017 16:31:18 +0100 Message-Id: <20171111153118.16038-1-johan@kernel.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171111014300.2982-1-sboyd@codeaurora.org> References: <20171111014300.2982-1-sboyd@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix bus-node lookup during registration, which ended up searching the whole device tree depth-first starting at the parent (or grand parent) rather than just matching on its children. To make things worse, the parent (or grand-parent) node could end being prematurely freed as well. Fixes: ef6a7bcfb01c ("usb: ulpi: Support device discovery via DT") Reported-by: Peter Robinson Reported-by: Stephen Boyd Cc: stable # 4.10 Signed-off-by: Johan Hovold --- drivers/usb/common/ulpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c index 8b351444cc40..9a2ab6751a23 100644 --- a/drivers/usb/common/ulpi.c +++ b/drivers/usb/common/ulpi.c @@ -180,9 +180,9 @@ static int ulpi_of_register(struct ulpi *ulpi) /* Find a ulpi bus underneath the parent or the grandparent */ parent = ulpi->dev.parent; if (parent->of_node) - np = of_find_node_by_name(parent->of_node, "ulpi"); + np = of_get_child_by_name(parent->of_node, "ulpi"); else if (parent->parent && parent->parent->of_node) - np = of_find_node_by_name(parent->parent->of_node, "ulpi"); + np = of_get_child_by_name(parent->parent->of_node, "ulpi"); if (!np) return 0; -- 2.15.0