From patchwork Mon Nov 28 18:24:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9449885 X-Patchwork-Delegate: geert@linux-m68k.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 68EE66071C for ; Mon, 28 Nov 2016 18:28:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FE3A27F9C for ; Mon, 28 Nov 2016 18:28:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 541E528047; Mon, 28 Nov 2016 18:28:12 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 D908827F9C for ; Mon, 28 Nov 2016 18:28:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753438AbcK1S1i (ORCPT ); Mon, 28 Nov 2016 13:27:38 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33722 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751332AbcK1S12 (ORCPT ); Mon, 28 Nov 2016 13:27:28 -0500 Received: by mail-lf0-f68.google.com with SMTP id 98so10305766lfs.0; Mon, 28 Nov 2016 10:27:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=zlor8Ptnd9pKa2uWKbeM4vV88uXfUHOFqQNekFxwhYU=; b=El8yeyWpxjIZc3zr0e6O6oaMuFf5miov2Lx1bTZRDvogdwzFmCm8+jkMjE7VOGNqvM h50e4IP3troDiX6F761yvpVpBswLW3RGSujriv0XZOfSKaD++r31hiy9dE48KYhpwxIa 996pgtbEgphlz+ru6qaPypBezRUgmrhjWG/6Xl9vWoJtEdocbf0jUJvNvHz+J6sH9jfO L1SP0+tuezuGYoYYsMxmX68uVv7E/fuofoiISMMC++uu7QOYLL++mniTwzjFSe+c/xRj 3tJIkkcehgupyYljRLznmqJqaurWa+PQeEtCRadS2vrxhmKtH1j5khszNecsySaUEO7B VrPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=zlor8Ptnd9pKa2uWKbeM4vV88uXfUHOFqQNekFxwhYU=; b=EbLtRHYWVZ3ZidYfBSnCuK0dPoIarosYtGjBxDbBe2jELFJ/yH3oQ7ockddxH5A3vD Rgf8TJ+h3cJoUHvNhuer6HKnvc5pLg19SgqJAV5JMNaglm854pk3+EghYTW4ajx7rna0 AyT/ewQN2L71yYCDY0cyel0J7PgSL1oBwwnkbtOfZlnLIUt8xgDCL9BSDv7xwLMw6Fsd QXGGi4Uf420jAXyF/KKW9wNSaZvI2nof8+lCMUCruX2zENljQJRLCVznwyh2ZeHHpCmu J8P6qii0m733FPlIv2YA9l5y6CK+PraAK4XdX8vHJMz0kvD6MKq45V5Gv+kHE76q4fHE ZVfw== X-Gm-Message-State: AKaTC018NDHsRVeBHm3C7r25pGK/UWlMnAIHRA3+QyzofArhDQv0RdWywx676fzLxsJHlA== X-Received: by 10.25.202.66 with SMTP id h2mr8567654lfj.131.1480357646428; Mon, 28 Nov 2016 10:27:26 -0800 (PST) Received: from xi.terra (c-04aadb54.07-184-6d6c6d4.cust.bredbandsbolaget.se. [84.219.170.4]) by smtp.gmail.com with ESMTPSA id n6sm269721lfd.42.2016.11.28.10.27.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 10:27:25 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.87) (envelope-from ) id 1cBQe9-0007K0-U0; Mon, 28 Nov 2016 19:27:21 +0100 From: Johan Hovold To: "David S. Miller" Cc: Vince Bridgers , Florian Fainelli , Fugang Duan , Pantelis Antoniou , Vitaly Bordug , Claudiu Manoil , Li Yang , Thomas Petazzoni , Felix Fietkau , John Crispin , Matthias Brugger , Sergei Shtylyov , Lars Persson , Mugunthan V N , Grygorii Strashko , Rob Herring , Frank Rowand , Andrew Lunn , Vivien Didelot , netdev@vger.kernel.org, nios2-dev@lists.rocketboards.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-omap@vger.kernel.org, devicetree@vger.kernel.org, Johan Hovold Subject: [PATCH net 01/16] net: dsa: slave: fix of-node leak and phy priority Date: Mon, 28 Nov 2016 19:24:54 +0100 Message-Id: <1480357509-28074-2-git-send-email-johan@kernel.org> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1480357509-28074-1-git-send-email-johan@kernel.org> References: <1480357509-28074-1-git-send-email-johan@kernel.org> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make sure to drop the reference taken by of_parse_phandle() before returning from dsa_slave_phy_setup(). Note that this also modifies the PHY priority so that any fixed-link node is only parsed when no phy-handle is given, which is in accordance with the common scheme for this. Fixes: 0d8bcdd383b8 ("net: dsa: allow for more complex PHY setups") Signed-off-by: Johan Hovold --- net/dsa/slave.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 6b1282c006b1..2a5c20a13fe4 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1125,7 +1125,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, p->phy_interface = mode; phy_dn = of_parse_phandle(port_dn, "phy-handle", 0); - if (of_phy_is_fixed_link(port_dn)) { + if (!phy_dn && of_phy_is_fixed_link(port_dn)) { /* In the case of a fixed PHY, the DT node associated * to the fixed PHY is the Port DT node */ @@ -1135,7 +1135,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, return ret; } phy_is_fixed = true; - phy_dn = port_dn; + phy_dn = of_node_get(port_dn); } if (ds->ops->get_phy_flags) @@ -1154,6 +1154,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, ret = dsa_slave_phy_connect(p, slave_dev, phy_id); if (ret) { netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret); + of_node_put(phy_dn); return ret; } } else { @@ -1162,6 +1163,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, phy_flags, p->phy_interface); } + + of_node_put(phy_dn); } if (p->phy && phy_is_fixed)