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: 700103 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tSFj45tbPz9tlW for ; Tue, 29 Nov 2016 05:35:04 +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: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3tSFj44q6szDvQC for ; Tue, 29 Nov 2016 05:35:04 +1100 (AEDT) Authentication-Results: lists.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 X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-lf0-x243.google.com (mail-lf0-x243.google.com [IPv6:2a00:1450:4010:c07::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3tSFXK4lpMzDvhR for ; Tue, 29 Nov 2016 05:27:29 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="El8yeyWp"; dkim-atps=neutral Received: by mail-lf0-x243.google.com with SMTP id p100so10340508lfg.2 for ; Mon, 28 Nov 2016 10:27:29 -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=JTESJpsBp0fUc1Zf2VTmhjG9rYFUNgzzE780lUHlEK2gYTndPaiWtGx8kTmBz+EE9z M59Ichul/Ol+AMNvB5N42TTBXHIUlB8NTKkKVmoPb1jFJ30gdCAIuMn5I0XGhj6GqT6L oEQsUPtF9eSbkvPeuoSET4IK2XsZjNuQ0F4zYsrL82pdU6sLhsRI3YvAfhracUZ0fea+ WEeBzBRDh8Lo4uD7g2HGeMo3HPJ7s1mzXJ1Lh89iev5gmSNic4HEiVc7gZZx90gbWxL8 ikYgfHdziisULsf8tTbzazGRa/HJ1s4DVsMKjVHLLaT+p32QOcekGSU+Bj+SHwrL5Zw0 MRzg== X-Gm-Message-State: AKaTC00yvLvrE7imDT9mTsfxPvRZ9LCbdo0VbOHEEfdRNuX0J4DnfmU4yO+AVB632rEOyw== 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-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , devicetree@vger.kernel.org, Frank Rowand , Felix Fietkau , Florian Fainelli , Claudiu Manoil , 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 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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)