Commit a3806872 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

devlink: take device reference for devlink object

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: c137743b ("devlink: introduce object and nested devlink relationship infra")
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c503bc7d
...@@ -310,6 +310,7 @@ static void devlink_release(struct work_struct *work) ...@@ -310,6 +310,7 @@ static void devlink_release(struct work_struct *work)
mutex_destroy(&devlink->lock); mutex_destroy(&devlink->lock);
lockdep_unregister_key(&devlink->lock_key); lockdep_unregister_key(&devlink->lock_key);
put_device(devlink->dev);
kfree(devlink); kfree(devlink);
} }
...@@ -425,7 +426,7 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops, ...@@ -425,7 +426,7 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops,
if (ret < 0) if (ret < 0)
goto err_xa_alloc; goto err_xa_alloc;
devlink->dev = dev; devlink->dev = get_device(dev);
devlink->ops = ops; devlink->ops = ops;
xa_init_flags(&devlink->ports, XA_FLAGS_ALLOC); xa_init_flags(&devlink->ports, XA_FLAGS_ALLOC);
xa_init_flags(&devlink->params, XA_FLAGS_ALLOC); xa_init_flags(&devlink->params, XA_FLAGS_ALLOC);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment