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: 700086 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3tSFXx751cz9vDw for ; Tue, 29 Nov 2016 05:28:01 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="El8yeyWp"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753751AbcK1S1j (ORCPT ); Mon, 28 Nov 2016 13:27:39 -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: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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)