[{"id":1774722,"web_url":"http://patchwork.ozlabs.org/comment/1774722/","msgid":"<20170925130944.GF19364@kwain>","list_archive_url":null,"date":"2017-09-25T13:09:44","subject":"Re: [PATCH net v2 2/3] net: mvpp2: fix port list indexing","submitter":{"id":61603,"url":"http://patchwork.ozlabs.org/api/people/61603/","name":"Antoine Tenart","email":"antoine.tenart@free-electrons.com"},"content":"On Mon, Sep 25, 2017 at 02:59:47PM +0200, Antoine Tenart wrote:\n> From: Yan Markman <ymarkman@marvell.com>\n> \n> The private port_list array has a list of pointers to mvpp2_port\n> instances. This list is allocated given the number of ports enabled in\n> the device tree, but the pointers are set using the port-id property. If\n> on a single port is enabled, the port_list array will be of size 1, but\n> when registering the port, if its id is not 0 the driver will crash.\n> Other crashes were encountered in various situations.\n> \n> This fixes the issue by using an index not equal to the value of the\n> port-id property.\n> \n> Fixes: 3f518509dedc (\"ethernet: Add new driver for Marvell Armada 375 network unit\")\n\nWith,\n\nSigned-off-by: Yan Markman <ymarkman@marvell.com>\n\nI don't know why it was removed, but this SoB should be added back.\n\nAntoine\n\n> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>\n> ---\n>  drivers/net/ethernet/marvell/mvpp2.c | 8 +++++---\n>  1 file changed, 5 insertions(+), 3 deletions(-)\n> \n> diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c\n> index da04939a2748..b2f99df81e9c 100644\n> --- a/drivers/net/ethernet/marvell/mvpp2.c\n> +++ b/drivers/net/ethernet/marvell/mvpp2.c\n> @@ -7504,7 +7504,7 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv,\n>  /* Ports initialization */\n>  static int mvpp2_port_probe(struct platform_device *pdev,\n>  \t\t\t    struct device_node *port_node,\n> -\t\t\t    struct mvpp2 *priv)\n> +\t\t\t    struct mvpp2 *priv, int index)\n>  {\n>  \tstruct device_node *phy_node;\n>  \tstruct phy *comphy;\n> @@ -7678,7 +7678,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,\n>  \t}\n>  \tnetdev_info(dev, \"Using %s mac address %pM\\n\", mac_from, dev->dev_addr);\n>  \n> -\tpriv->port_list[id] = port;\n> +\tpriv->port_list[index] = port;\n>  \treturn 0;\n>  \n>  err_free_port_pcpu:\n> @@ -8013,10 +8013,12 @@ static int mvpp2_probe(struct platform_device *pdev)\n>  \t}\n>  \n>  \t/* Initialize ports */\n> +\ti = 0;\n>  \tfor_each_available_child_of_node(dn, port_node) {\n> -\t\terr = mvpp2_port_probe(pdev, port_node, priv);\n> +\t\terr = mvpp2_port_probe(pdev, port_node, priv, i);\n>  \t\tif (err < 0)\n>  \t\t\tgoto err_mg_clk;\n> +\t\ti++;\n>  \t}\n>  \n>  \tplatform_set_drvdata(pdev, priv);\n> -- \n> 2.13.5\n>","headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3y14F15Gk4z9sRW\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 25 Sep 2017 23:09:57 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S964838AbdIYNJs (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 25 Sep 2017 09:09:48 -0400","from mail.free-electrons.com ([62.4.15.54]:43586 \"EHLO\n\tmail.free-electrons.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S964816AbdIYNJq (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 25 Sep 2017 09:09:46 -0400","by mail.free-electrons.com (Postfix, from userid 110)\n\tid 38C00207FE; Mon, 25 Sep 2017 15:09:44 +0200 (CEST)","from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr\n\t[90.63.216.87])\n\tby mail.free-electrons.com (Postfix) with ESMTPSA id 0BA74207C5;\n\tMon, 25 Sep 2017 15:09:44 +0200 (CEST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on\n\tmail.free-electrons.com","X-Spam-Level":"","X-Spam-Status":"No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT,\n\tURIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0","Date":"Mon, 25 Sep 2017 15:09:44 +0200","From":"Antoine Tenart <antoine.tenart@free-electrons.com>","To":"davem@davemloft.net","Cc":"Yan Markman <ymarkman@marvell.com>, andrew@lunn.ch,\n\tgregory.clement@free-electrons.com, thomas.petazzoni@free-electrons.com,\n\tmiquel.raynal@free-electrons.com, nadavh@marvell.com,\n\tlinux@armlinux.org.uk, linux-kernel@vger.kernel.org,\n\tmw@semihalf.com, stefanc@marvell.com, netdev@vger.kernel.org,\n\tAntoine Tenart <antoine.tenart@free-electrons.com>","Subject":"Re: [PATCH net v2 2/3] net: mvpp2: fix port list indexing","Message-ID":"<20170925130944.GF19364@kwain>","References":"<20170925125948.13507-1-antoine.tenart@free-electrons.com>\n\t<20170925125948.13507-3-antoine.tenart@free-electrons.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20170925125948.13507-3-antoine.tenart@free-electrons.com>","User-Agent":"Mutt/1.9.0 (2017-09-02)","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"}}]