lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201130131335.afasdxbf5ilhsxue@mchp-dev-shegelun>
Date:   Mon, 30 Nov 2020 14:13:35 +0100
From:   Steen Hegelund <steen.hegelund@...rochip.com>
To:     Andrew Lunn <andrew@...n.ch>
CC:     "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Masahiro Yamada <masahiroy@...nel.org>,
        Lars Povlsen <lars.povlsen@...rochip.com>,
        Bjarni Jonasson <bjarni.jonasson@...rochip.com>,
        Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Microsemi List <microsemi@...ts.bootlin.com>,
        <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH 2/3] net: sparx5: Add Sparx5 switchdev driver

On 27.11.2020 18:15, Andrew Lunn wrote:
>EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
>This is a very large driver, which is going to make it slow to review.
Hi Andrew,

Yes I am aware of that, but I think that what is available with this
series, makes for a nice package that can be tested by us, and used by
our customers.

>
>> +static int sparx5_probe_port(struct sparx5 *sparx5,
>> +                          struct device_node *portnp,
>> +                          struct phy *serdes,
>> +                          u32 portno,
>> +                          struct sparx5_port_config *conf)
>> +{
>> +     phy_interface_t phy_mode = conf->phy_mode;
>> +     struct sparx5_port *spx5_port;
>> +     struct net_device *ndev;
>> +     struct phylink *phylink;
>> +     int err;
>> +
>> +     err = sparx5_create_targets(sparx5);
>> +     if (err)
>> +             return err;
>> +     ndev = sparx5_create_netdev(sparx5, portno);
>> +     if (IS_ERR(ndev)) {
>> +             dev_err(sparx5->dev, "Could not create net device: %02u\n", portno);
>> +             return PTR_ERR(ndev);
>> +     }
>> +     spx5_port = netdev_priv(ndev);
>> +     spx5_port->of_node = portnp;
>> +     spx5_port->serdes = serdes;
>> +     spx5_port->pvid = NULL_VID;
>> +     spx5_port->signd_internal = true;
>> +     spx5_port->signd_active_high = true;
>> +     spx5_port->signd_enable = true;
>> +     spx5_port->flow_control = false;
>> +     spx5_port->max_vlan_tags = SPX5_PORT_MAX_TAGS_NONE;
>> +     spx5_port->vlan_type = SPX5_VLAN_PORT_TYPE_UNAWARE;
>> +     spx5_port->custom_etype = 0x8880; /* Vitesse */
>> +     conf->portmode = conf->phy_mode;
>> +     spx5_port->conf.speed = SPEED_UNKNOWN;
>> +     spx5_port->conf.power_down = true;
>> +     sparx5->ports[portno] = spx5_port;
>
>
>> +struct net_device *sparx5_create_netdev(struct sparx5 *sparx5, u32 portno)
>> +{
>> +     struct net_device *ndev;
>> +     struct sparx5_port *spx5_port;
>> +     int err;
>> +
>> +     ndev = devm_alloc_etherdev(sparx5->dev, sizeof(struct sparx5_port));
>> +     if (!ndev)
>> +             return ERR_PTR(-ENOMEM);
>> +
>
>...
>
>> +     err = register_netdev(ndev);
>> +     if (err) {
>> +             dev_err(sparx5->dev, "netdev registration failed\n");
>> +             return ERR_PTR(err);
>> +     }
>
>This is one of the classic bugs in network drivers. As soon as you
>call register_netdev() the interface is live. The network stack can
>start using it. But you have not finished initialzing spx5_port. So
>bad things are going to happen.

Oops.  I will fix that.

Thanks for the comments.
Steen
>
>    Andrew

BR
Steen

---------------------------------------
Steen Hegelund
steen.hegelund@...rochip.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ