Re: [PATCH net-next RFC v4 01/15] devlink: Add reload action option to devlink reload command

Jiri Pirko
2020-09-16T00:36:29Z

Tue, Sep 15, 2020 at 02:12:25PM CEST, moshe@nvidia.com wrote:
>
>On 9/14/2020 3:27 PM, Jiri Pirko wrote:
>> Mon, Sep 14, 2020 at 08:07:48AM CEST, moshe@mellanox.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;
>> > + } …