]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
module: sysfs: Drop member 'module_sect_attr::address'
authorThomas Weißschuh <linux@weissschuh.net>
Fri, 27 Dec 2024 13:23:21 +0000 (14:23 +0100)
committerPetr Pavlu <petr.pavlu@suse.com>
Sun, 26 Jan 2025 12:05:24 +0000 (13:05 +0100)
'struct bin_attribute' already contains the member 'private' to pass
custom data to the attribute handlers.
Use that instead of the custom 'address' member.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20241227-sysfs-const-bin_attr-module-v2-2-e267275f0f37@weissschuh.net
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
kernel/module/sysfs.c

index 31351591e8e0e031879d1d249878cf4281ef37fb..6941ecc941d7c853c5a3dc9b905a563959c6af3a 100644 (file)
@@ -21,7 +21,6 @@
 #ifdef CONFIG_KALLSYMS
 struct module_sect_attr {
        struct bin_attribute battr;
-       unsigned long address;
 };
 
 struct module_sect_attrs {
@@ -34,8 +33,6 @@ static ssize_t module_sect_read(struct file *file, struct kobject *kobj,
                                struct bin_attribute *battr,
                                char *buf, loff_t pos, size_t count)
 {
-       struct module_sect_attr *sattr =
-               container_of(battr, struct module_sect_attr, battr);
        char bounce[MODULE_SECT_READ_SIZE + 1];
        size_t wrote;
 
@@ -52,7 +49,7 @@ static ssize_t module_sect_read(struct file *file, struct kobject *kobj,
         */
        wrote = scnprintf(bounce, sizeof(bounce), "0x%px\n",
                          kallsyms_show_value(file->f_cred)
-                               ? (void *)sattr->address : NULL);
+                               ? battr->private : NULL);
        count = min(count, wrote);
        memcpy(buf, bounce, count);
 
@@ -99,7 +96,6 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
                if (sect_empty(sec))
                        continue;
                sysfs_bin_attr_init(&sattr->battr);
-               sattr->address = sec->sh_addr;
                sattr->battr.attr.name =
                        kstrdup(info->secstrings + sec->sh_name, GFP_KERNEL);
                if (!sattr->battr.attr.name) {
@@ -107,6 +103,7 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
                        goto out;
                }
                sattr->battr.read = module_sect_read;
+               sattr->battr.private = (void *)sec->sh_addr;
                sattr->battr.size = MODULE_SECT_READ_SIZE;
                sattr->battr.attr.mode = 0400;
                *(gattr++) = &(sattr++)->battr;