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


OK, will fix.

+               kfree(devlink);
+               return NULL;
+       }
[...]

Reply via email to