[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YBwoKiRlOmi3my5G@lunn.ch>
Date: Thu, 4 Feb 2021 18:00:26 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Vladimir Oltean <vladimir.oltean@....com>
Cc: "David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
netdev <netdev@...r.kernel.org>,
Florian Fainelli <f.fainelli@...il.com>,
Vivien Didelot <vivien.didelot@...il.com>
Subject: Re: [PATCH net] net: dsa: call teardown method on probe failure
On Thu, Feb 04, 2021 at 06:33:51PM +0200, Vladimir Oltean wrote:
> Since teardown is supposed to undo the effects of the setup method, it
> should be called in the error path for dsa_switch_setup, not just in
> dsa_switch_teardown.
I disagree with this. If setup failed, it should of cleaned itself up.
That is the generally accepted way of doing things. If a function is
going to exit with an error, it should first undo whatever it did
before exiting.
You are adding extra semantics to the teardown op. It can no longer
assume setup was successful. So it needs to be very careful about what
it tears down, it cannot assume everything has been setup. I doubt the
existing implementations actually do that.
Andrew
Powered by blists - more mailing lists