]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
firmware: memmap: Constify memmap_ktype
authorKunwu Chan <chentao@kylinos.cn>
Tue, 24 Sep 2024 03:05:32 +0000 (11:05 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Oct 2024 15:22:33 +0000 (17:22 +0200)
This 'memmap_ktype' is not modified. It is only used in
firmware_map_add_entry().

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
   4345     596      12    4953    1359 drivers/firmware/memmap.o

[After]
   text    data     bss     dec     hex filename
   4393     548      12    4953    1359 drivers/firmware/memmap.o
```

Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
Link: https://lore.kernel.org/r/20240924030533.34407-1-chentao@kylinos.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/firmware/memmap.c

index 8e59be3782cbb7532e2f655410bf18e1ba7966f8..55b9cfad8a042b3b21cf703cd5982febf0886669 100644 (file)
@@ -116,7 +116,7 @@ static void __meminit release_firmware_map_entry(struct kobject *kobj)
        kfree(entry);
 }
 
-static struct kobj_type __refdata memmap_ktype = {
+static const struct kobj_type memmap_ktype = {
        .release        = release_firmware_map_entry,
        .sysfs_ops      = &memmap_attr_ops,
        .default_groups = def_groups,