Skip to content

Commit 4b2c11e

Browse files
t-8chpetrpavlu
authored andcommitted
module: sysfs: Drop member 'module_sect_attr::address'
'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 <[email protected]> Reviewed-by: Petr Pavlu <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/20241227-sysfs-const-bin_attr-module-v2-2-e267275f0f37@weissschuh.net Signed-off-by: Petr Pavlu <[email protected]>
1 parent d8959b9 commit 4b2c11e

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

kernel/module/sysfs.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#ifdef CONFIG_KALLSYMS
2222
struct module_sect_attr {
2323
struct bin_attribute battr;
24-
unsigned long address;
2524
};
2625

2726
struct module_sect_attrs {
@@ -34,8 +33,6 @@ static ssize_t module_sect_read(struct file *file, struct kobject *kobj,
3433
struct bin_attribute *battr,
3534
char *buf, loff_t pos, size_t count)
3635
{
37-
struct module_sect_attr *sattr =
38-
container_of(battr, struct module_sect_attr, battr);
3936
char bounce[MODULE_SECT_READ_SIZE + 1];
4037
size_t wrote;
4138

@@ -52,7 +49,7 @@ static ssize_t module_sect_read(struct file *file, struct kobject *kobj,
5249
*/
5350
wrote = scnprintf(bounce, sizeof(bounce), "0x%px\n",
5451
kallsyms_show_value(file->f_cred)
55-
? (void *)sattr->address : NULL);
52+
? battr->private : NULL);
5653
count = min(count, wrote);
5754
memcpy(buf, bounce, count);
5855

@@ -99,14 +96,14 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info)
9996
if (sect_empty(sec))
10097
continue;
10198
sysfs_bin_attr_init(&sattr->battr);
102-
sattr->address = sec->sh_addr;
10399
sattr->battr.attr.name =
104100
kstrdup(info->secstrings + sec->sh_name, GFP_KERNEL);
105101
if (!sattr->battr.attr.name) {
106102
ret = -ENOMEM;
107103
goto out;
108104
}
109105
sattr->battr.read = module_sect_read;
106+
sattr->battr.private = (void *)sec->sh_addr;
110107
sattr->battr.size = MODULE_SECT_READ_SIZE;
111108
sattr->battr.attr.mode = 0400;
112109
*(gattr++) = &(sattr++)->battr;

0 commit comments

Comments
 (0)