]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/lima: Constify 'struct bin_attribute'
authorThomas Weißschuh <linux@weissschuh.net>
Mon, 16 Dec 2024 11:34:48 +0000 (12:34 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Feb 2025 08:20:31 +0000 (09:20 +0100)
The sysfs core now allows instances of 'struct bin_attribute' to be
moved into read-only memory. Make use of that to protect them against
accidental or malicious modifications.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://lore.kernel.org/r/20241216-sysfs-const-bin_attr-drm-v1-2-210f2b36b9bf@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/lima/lima_drv.c

index 2067c5b65c57990e5ea6436965fc4f10a3167a21..11ace5cebf4c81b5d863efb0ad13dfcfc2373f7a 100644 (file)
@@ -310,7 +310,7 @@ static bool lima_read_block(struct lima_block_reader *reader,
 }
 
 static ssize_t lima_error_state_read(struct file *filp, struct kobject *kobj,
-                                    struct bin_attribute *attr, char *buf,
+                                    const struct bin_attribute *attr, char *buf,
                                     loff_t off, size_t count)
 {
        struct device *dev = kobj_to_dev(kobj);
@@ -336,7 +336,7 @@ static ssize_t lima_error_state_read(struct file *filp, struct kobject *kobj,
 }
 
 static ssize_t lima_error_state_write(struct file *file, struct kobject *kobj,
-                                     struct bin_attribute *attr, char *buf,
+                                     const struct bin_attribute *attr, char *buf,
                                      loff_t off, size_t count)
 {
        struct device *dev = kobj_to_dev(kobj);
@@ -362,8 +362,8 @@ static const struct bin_attribute lima_error_state_attr = {
        .attr.name = "error",
        .attr.mode = 0600,
        .size = 0,
-       .read = lima_error_state_read,
-       .write = lima_error_state_write,
+       .read_new = lima_error_state_read,
+       .write_new = lima_error_state_write,
 };
 
 static int lima_pdev_probe(struct platform_device *pdev)