[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200918152826.GB9675@piout.net>
Date: Fri, 18 Sep 2020 17:28:26 +0200
From: Alexandre Belloni <alexandre.belloni@...tlin.com>
To: Vladimir Oltean <olteanv@...il.com>
Cc: davem@...emloft.net, netdev@...r.kernel.org, yangbo.lu@....com,
xiaoliang.yang_1@....com, UNGLinuxDriver@...rochip.com,
claudiu.manoil@....com, andrew@...n.ch, vivien.didelot@...il.com,
f.fainelli@...il.com, kuba@...nel.org
Subject: Re: [PATCH v2 net 5/8] net: mscc: ocelot: error checking when
calling ocelot_init()
On 18/09/2020 04:07:27+0300, Vladimir Oltean wrote:
> From: Vladimir Oltean <vladimir.oltean@....com>
>
> ocelot_init() allocates memory, resets the switch and polls for a status
> register, things which can fail. Stop probing the driver in that case,
> and propagate the error result.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
> Reviewed-by: Horatiu Vultur <horatiu.vultur@...rochip.com>
Tested-by: Alexandre Belloni <alexandre.belloni@...tlin.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@...tlin.com>
> ---
> Changes in v2:
> Stopped leaking the 'ports' OF node in the VSC7514 driver.
>
> drivers/net/dsa/ocelot/felix.c | 5 ++++-
> drivers/net/ethernet/mscc/ocelot_vsc7514.c | 5 ++++-
> 2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
> index a1e1d3824110..f7b43f8d56ed 100644
> --- a/drivers/net/dsa/ocelot/felix.c
> +++ b/drivers/net/dsa/ocelot/felix.c
> @@ -571,7 +571,10 @@ static int felix_setup(struct dsa_switch *ds)
> if (err)
> return err;
>
> - ocelot_init(ocelot);
> + err = ocelot_init(ocelot);
> + if (err)
> + return err;
> +
> if (ocelot->ptp) {
> err = ocelot_init_timestamp(ocelot, &ocelot_ptp_clock_info);
> if (err) {
> diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
> index 904ea299a5e8..a1cbb20a7757 100644
> --- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c
> +++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
> @@ -1002,7 +1002,10 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
> ocelot->vcap_is2_actions = vsc7514_vcap_is2_actions;
> ocelot->vcap = vsc7514_vcap_props;
>
> - ocelot_init(ocelot);
> + err = ocelot_init(ocelot);
> + if (err)
> + goto out_put_ports;
> +
> if (ocelot->ptp) {
> err = ocelot_init_timestamp(ocelot, &ocelot_ptp_clock_info);
> if (err) {
> --
> 2.25.1
>
--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Powered by blists - more mailing lists