path: root/drivers/infiniband/core/uverbs_ioctl.c
diff options
authorJason Gunthorpe <jgg@mellanox.com>2018-08-09 20:14:37 -0600
committerJason Gunthorpe <jgg@mellanox.com>2018-08-10 16:06:24 -0600
commit6b0d08f4a27134e6fb49aa33ceb53356081bc92e (patch)
tree7781178fde4ef9aeb01acf736274de2fca581a5a /drivers/infiniband/core/uverbs_ioctl.c
parentIB/uverbs: Build the specs into a radix tree at runtime (diff)
IB/uverbs: Use uverbs_api to manage the object type inside the uobject
Currently the struct uverbs_obj_type stored in the ib_uobject is part of the .rodata segment of the module that defines the object. This is a problem if drivers define new uapi objects as we will be left with a dangling pointer after device disassociation. Switch the uverbs_obj_type for struct uverbs_api_object, which is allocated memory that is part of the uverbs_api and is guaranteed to always exist. Further this moves the 'type_class' into this memory which means access to the IDR/FD function pointers is also guaranteed. Drivers cannot define new types. This makes it safe to continue to use all uobjects, including driver defined ones, after disassociation. Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/core/uverbs_ioctl.c')
1 files changed, 1 insertions, 5 deletions
diff --git a/drivers/infiniband/core/uverbs_ioctl.c b/drivers/infiniband/core/uverbs_ioctl.c
index 23ff698ab08e..8a052d0fdf2c 100644
--- a/drivers/infiniband/core/uverbs_ioctl.c
+++ b/drivers/infiniband/core/uverbs_ioctl.c
@@ -57,7 +57,6 @@ static int uverbs_process_attr(struct ib_uverbs_file *ufile,
const struct uverbs_attr_spec *spec;
const struct uverbs_attr_spec *val_spec;
struct uverbs_attr *e;
- const struct uverbs_object_spec *object;
struct uverbs_obj_attr *o_attr;
struct uverbs_attr *elements = attr_bundle_h->attrs;
@@ -145,9 +144,6 @@ static int uverbs_process_attr(struct ib_uverbs_file *ufile,
return -EINVAL;
o_attr = &e->obj_attr;
- object = uverbs_get_object(ufile, spec->u.obj.obj_type);
- if (!object)
- return -EINVAL;
/* specs are allowed to have only one destroy attribute */
WARN_ON(spec->u.obj.access == UVERBS_ACCESS_DESTROY &&
@@ -162,7 +158,7 @@ static int uverbs_process_attr(struct ib_uverbs_file *ufile,
* IDR implementation today rejects negative IDs
o_attr->uobject = uverbs_get_uobject_from_file(
- object->type_attrs,
+ spec->u.obj.obj_type,