diff options
| author | Thomas Weißschuh <linux@weissschuh.net> | 2026-02-23 22:16:30 +0100 |
|---|---|---|
| committer | Borislav Petkov (AMD) <bp@alien8.de> | 2026-03-11 22:20:11 +0100 |
| commit | 495e77a575a1f3637cfc0cff53d889316dd00594 (patch) | |
| tree | 4b68758c15d3d1b493361d63e5c620c98710d854 /drivers | |
| parent | c43c3b8fb39a3cc96f0cea9ca30e3e39ec696490 (diff) | |
EDAC/device: Drop unnecessary and dangerous casts of attributes
These casts assume that the struct attribute is at the beginning of struct
edac_dev_sysfs_block_attribute. This is can silently break if the field is
moved, either manually or through struct randomization.
Use proper member syntax to get the field address and drop the casts.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://patch.msgid.link/20260223-sysfs-const-edac-v1-3-3ff0b87249e7@weissschuh.net
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/edac/edac_device_sysfs.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c index 9cc466b78982..1e79f36a91fa 100644 --- a/drivers/edac/edac_device_sysfs.c +++ b/drivers/edac/edac_device_sysfs.c @@ -573,8 +573,7 @@ static void edac_device_delete_block(struct edac_device_ctl_info *edac_dev, for (i = 0; i < block->nr_attribs; i++, sysfs_attrib++) { /* remove each block_attrib file */ - sysfs_remove_file(&block->kobj, - (struct attribute *) sysfs_attrib); + sysfs_remove_file(&block->kobj, &sysfs_attrib->attr); } } @@ -734,7 +733,7 @@ static int edac_device_add_main_sysfs_attributes( */ while (sysfs_attrib->attr.name != NULL) { err = sysfs_create_file(&edac_dev->kobj, - (struct attribute*) sysfs_attrib); + &sysfs_attrib->attr); if (err) goto err_out; @@ -762,8 +761,7 @@ static void edac_device_remove_main_sysfs_attributes( sysfs_attrib = edac_dev->sysfs_attributes; if (sysfs_attrib) { while (sysfs_attrib->attr.name != NULL) { - sysfs_remove_file(&edac_dev->kobj, - (struct attribute *) sysfs_attrib); + sysfs_remove_file(&edac_dev->kobj, &sysfs_attrib->attr); sysfs_attrib++; } } |
