From patchwork Sat Nov 11 15:31:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 10054387 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3628A60632 for ; Sat, 11 Nov 2017 15:31:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 624C9298AC for ; Sat, 11 Nov 2017 15:31:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 569A529A2D; Sat, 11 Nov 2017 15:31:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E30C72984D for ; Sat, 11 Nov 2017 15:31:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750832AbdKKPbs (ORCPT ); Sat, 11 Nov 2017 10:31:48 -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 Received: by mail-lf0-f66.google.com with SMTP id r135so14053864lfe.5; Sat, 11 Nov 2017 07:31:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=wDb4LgRhYWyH9W5E+Kk4Nhcy1OwjzZgZIFwb+vT/RQ8=; b=G5BTosDkzcMCjkBseLLLxhtXuajyfo7r6OUfWOnOCywLmZdA4vPnDXq2g3W/Pjj+3e bFSS4TzZTTlGm/ZVtAufJWzaCqGB984DwZ7AnnT0pHnrs9dnhdxqymsl/ee5cAPFN1f6 lymOkTTELaGTmbpWXLfBx+qUhUK2ObtJNrBqe1dDYa1ndJSdKVw9YLfwHddZQROmpCgG mxZUKqhydhdM3YMtMbRiO0K1HWMeDzNlADExTuvcfS3CzT1Da492xSTtcAyBfDY3Wu8q choRk5lgK3eUPSxug0PkUHmYsg9ZprIw5bXDXY13HSSSofzdzRDe1GRIRfNdkTZ7mTXE kWlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=wDb4LgRhYWyH9W5E+Kk4Nhcy1OwjzZgZIFwb+vT/RQ8=; b=OR/ry4WAcQxgLmduBkBZ9i36hhsA5WY/gu7l60ktCpYgP8KYDKjh23QJVbPgFiKhzW HM23zixum48onQvZYFAscfdsGkvzuBM7tQbKljcAr4fSODVURT7nHNhax0pchne6IKN8 1U/A0JULjy5DrxMcw/zeWXWKZBgKmIGO1NXtt4Ao0bNm0FsuVb77vCNDeCMfFSeYqD9Q F+pVlqJ5gH9JL/KSamrjqug2AlcBNEkowhINRZN9dcxLa/5ngWckzgkXlg+T9vHrynoH 46YAW3rtZm7dt/uzHJtFKFfFucrGDdWpJwxNozTDvcB0s/Nzfdb/DAvhW2XYoo1MKZ4w YuGw== X-Gm-Message-State: AJaThX6M0sYZK3FhCYbAu88KRQmQj3kffF5LFNw79ob6sDUOBSCAtjGR j4zMrsYOBpa5B22mJMqBSFA= X-Google-Smtp-Source: AGs4zMZUtFQCLGjExUFL5MZmvmLWY7dpDkqVNuusM82ZjWt8XVS+S0dGVi7plXwsoz3mmTsQJ2vZ8Q== X-Received: by 10.25.221.217 with SMTP id w86mr1056772lfi.89.1510414304798; Sat, 11 Nov 2017 07:31:44 -0800 (PST) Received: from xi.terra (c-c0bae655.07-184-6d6c6d4.cust.bredbandsbolaget.se. [85.230.186.192]) by smtp.gmail.com with ESMTPSA id s76sm2112200lfi.56.2017.11.11.07.31.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Nov 2017 07:31:44 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1eDXl7-0004BO-LN; Sat, 11 Nov 2017 16:31:49 +0100 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;