]> Git Repo - linux.git/commitdiff
devlink: take device reference for devlink object
authorJiri Pirko <[email protected]>
Fri, 13 Oct 2023 12:10:25 +0000 (14:10 +0200)
committerDavid S. Miller <[email protected]>
Wed, 18 Oct 2023 08:23:01 +0000 (09:23 +0100)
In preparation to allow to access device pointer without devlink
instance lock held, make sure the device pointer is usable until
devlink_release() is called.

Fixes: c137743bce02 ("devlink: introduce object and nested devlink relationship infra")
Signed-off-by: Jiri Pirko <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
net/devlink/core.c

index bcbbb952569f559a69bf6afc00be35ed330174c2..c47c9e6c744fed393fce7a62335166b3bb69772f 100644 (file)
@@ -310,6 +310,7 @@ static void devlink_release(struct work_struct *work)
 
        mutex_destroy(&devlink->lock);
        lockdep_unregister_key(&devlink->lock_key);
+       put_device(devlink->dev);
        kfree(devlink);
 }
 
@@ -425,7 +426,7 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops,
        if (ret < 0)
                goto err_xa_alloc;
 
-       devlink->dev = dev;
+       devlink->dev = get_device(dev);
        devlink->ops = ops;
        xa_init_flags(&devlink->ports, XA_FLAGS_ALLOC);
        xa_init_flags(&devlink->params, XA_FLAGS_ALLOC);
This page took 0.050904 seconds and 4 git commands to generate.