Commit 27a8204b authored by Hongbo Li's avatar Hongbo Li Committed by Alex Williamson

vfio/mdev: Constify struct kobj_type

This 'struct kobj_type' is not modified. It is only used in
kobject_init_and_add() which takes a 'const struct kobj_type *ktype'
parameter.

Constifying this structure and moving it to a read-only section,
and this can increase over all security.

```
[Before]
   text   data    bss    dec    hex    filename
   2372    600      0   2972    b9c    drivers/vfio/mdev/mdev_sysfs.o

[After]
   text   data    bss    dec    hex    filename
   2436    568      0   3004    bbc    drivers/vfio/mdev/mdev_sysfs.o
```
Signed-off-by: default avatarHongbo Li <lihongbo22@huawei.com>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20240904011837.2010444-1-lihongbo22@huawei.comSigned-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent 7555c7d2
...@@ -160,7 +160,7 @@ static void mdev_type_release(struct kobject *kobj) ...@@ -160,7 +160,7 @@ static void mdev_type_release(struct kobject *kobj)
put_device(type->parent->dev); put_device(type->parent->dev);
} }
static struct kobj_type mdev_type_ktype = { static const struct kobj_type mdev_type_ktype = {
.sysfs_ops = &mdev_type_sysfs_ops, .sysfs_ops = &mdev_type_sysfs_ops,
.release = mdev_type_release, .release = mdev_type_release,
.default_groups = mdev_type_groups, .default_groups = mdev_type_groups,
......
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