]> Git Repo - linux.git/commitdiff
vfio/mdev: Constify struct kobj_type
authorHongbo Li <[email protected]>
Wed, 4 Sep 2024 01:18:37 +0000 (09:18 +0800)
committerAlex Williamson <[email protected]>
Fri, 6 Sep 2024 14:20:52 +0000 (08:20 -0600)
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: Hongbo Li <[email protected]>
Reviewed-by: Jason Gunthorpe <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alex Williamson <[email protected]>
drivers/vfio/mdev/mdev_sysfs.c

index 9d2738e10c0b9d4d2b1018e4c948bf427d0315a9..e44bb44c581e2fb6ca5dc07a81fccf70eb51bd66 100644 (file)
@@ -160,7 +160,7 @@ static void mdev_type_release(struct kobject *kobj)
        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,
        .release        = mdev_type_release,
        .default_groups = mdev_type_groups,
This page took 0.057982 seconds and 4 git commands to generate.