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: 9449903 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 6004B6071C for ; Mon, 28 Nov 2016 18:28:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5447427F9C for ; Mon, 28 Nov 2016 18:28:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48E1C27FB6; Mon, 28 Nov 2016 18:28:18 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0448227F9C for ; Mon, 28 Nov 2016 18:28:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBQf3-0001bY-Cd; Mon, 28 Nov 2016 18:28:17 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBQea-00013K-9K for linux-mediatek@lists.infradead.org; Mon, 28 Nov 2016 18:27:54 +0000 Received: by mail-lf0-x243.google.com with SMTP id 98so10305761lfs.0 for ; 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=eSstz3gUuJX8EU69KgQzf6jiUU3k7nUkYexl/hQEyZrEl3Gu4ViR3V8QeJwDayW/LO 6RooEhTFjXc1PQO5XbtGvIutewCiDar3+3aoRZq53B1xSNHfaK7mtbl+xfT86i5ACLko 00FmvewYV3hDe4a0Bkx/vxNLK6xZNNKvXcjmFzeT2zCH1YbS7N8di7lijK3R6xCEogeJ E8rMFtHqn4SWCt79AmdkOzSbyq7CGK2P72sYOR4tesZndxInaOjSt3Kmj+Frkhi04LQJ 792O6mekYwZqVaI6WlBmBokUUsiFptBGyntvffQ4n74G4a+wVwezCxW33Mqck3ZIjEI9 lumw== X-Gm-Message-State: AKaTC01atZTY1TuJXnAaV8CtMydJv1ys+fM9fjEA7I6K6WK6XZAgudk1QXPOOxCJA/I2ng== 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" 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161128_102748_915098_07D6B101 X-CRM114-Status: GOOD ( 12.90 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , devicetree@vger.kernel.org, Pantelis Antoniou , Frank Rowand , Felix Fietkau , Florian Fainelli , Claudiu Manoil , Li Yang , Mugunthan V N , Grygorii Strashko , linuxppc-dev@lists.ozlabs.org, Johan Hovold , Rob Herring , linux-mediatek@lists.infradead.org, Lars Persson , Matthias Brugger , linux-omap@vger.kernel.org, John Crispin , Thomas Petazzoni , Fugang Duan , Sergei Shtylyov , Vivien Didelot , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Vitaly Bordug , nios2-dev@lists.rocketboards.org, Vince Bridgers MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.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)