[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200915132614.GN2236@nanopsycho.orion>
Date: Tue, 15 Sep 2020 15:26:14 +0200
From: Jiri Pirko <jiri@...nulli.us>
To: Moshe Shemesh <moshe@...dia.com>
Cc: Moshe Shemesh <moshe@...lanox.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Jiri Pirko <jiri@...lanox.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next RFC v4 01/15] devlink: Add reload action option
to devlink reload command
Tue, Sep 15, 2020 at 02:12:25PM CEST, moshe@...dia.com wrote:
>
>On 9/14/2020 3:27 PM, Jiri Pirko wrote:
>> Mon, Sep 14, 2020 at 08:07:48AM CEST, moshe@...lanox.com wrote:
[..]
>> > @@ -7392,6 +7485,11 @@ struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size)
>> > if (!devlink)
>> > return NULL;
>> > devlink->ops = ops;
>> > + if (devlink_reload_actions_verify(devlink)) {
>> Move this check to the beginning. You don't need devlink instance for
>> the check, just ops.
>
>
>Right, will fix.
>
>> also, your devlink_reload_actions_verify() function returns
>> 0/-ESOMETHING. Treat it accordingly here.
>
>
>Well, yes, but I rather return NULL here since devlink_alloc() failed. If
>devlink_reload_actions_verify() fails it has WARN_ON which will lead the
>driver developer to his bug.
So let the verify() return bool.
My point is, if a function return 0/-ESOMETHING, you should not check
the return value directly but you should use int err/ret.
>
>>
>> > + kfree(devlink);
>> > + return NULL;
>> > + }
[...]
Powered by blists - more mailing lists