mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-06 00:47:56 -04:00
scsi: 3w-sas: Constify 'struct bin_attribute'
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> Link: https://lore.kernel.org/r/20241216-sysfs-const-bin_attr-scsi-v1-2-f0a5e54b3437@weissschuh.net Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
committed by
Martin K. Petersen
parent
e4dab5d1de
commit
1cf448bd2e
@@ -96,7 +96,7 @@ static int twl_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_res
|
||||
|
||||
/* This function returns AENs through sysfs */
|
||||
static ssize_t twl_sysfs_aen_read(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *bin_attr,
|
||||
const struct bin_attribute *bin_attr,
|
||||
char *outbuf, loff_t offset, size_t count)
|
||||
{
|
||||
struct device *dev = container_of(kobj, struct device, kobj);
|
||||
@@ -116,18 +116,18 @@ static ssize_t twl_sysfs_aen_read(struct file *filp, struct kobject *kobj,
|
||||
} /* End twl_sysfs_aen_read() */
|
||||
|
||||
/* aen_read sysfs attribute initializer */
|
||||
static struct bin_attribute twl_sysfs_aen_read_attr = {
|
||||
static const struct bin_attribute twl_sysfs_aen_read_attr = {
|
||||
.attr = {
|
||||
.name = "3ware_aen_read",
|
||||
.mode = S_IRUSR,
|
||||
},
|
||||
.size = 0,
|
||||
.read = twl_sysfs_aen_read
|
||||
.read_new = twl_sysfs_aen_read
|
||||
};
|
||||
|
||||
/* This function returns driver compatibility info through sysfs */
|
||||
static ssize_t twl_sysfs_compat_info(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *bin_attr,
|
||||
const struct bin_attribute *bin_attr,
|
||||
char *outbuf, loff_t offset, size_t count)
|
||||
{
|
||||
struct device *dev = container_of(kobj, struct device, kobj);
|
||||
@@ -147,13 +147,13 @@ static ssize_t twl_sysfs_compat_info(struct file *filp, struct kobject *kobj,
|
||||
} /* End twl_sysfs_compat_info() */
|
||||
|
||||
/* compat_info sysfs attribute initializer */
|
||||
static struct bin_attribute twl_sysfs_compat_info_attr = {
|
||||
static const struct bin_attribute twl_sysfs_compat_info_attr = {
|
||||
.attr = {
|
||||
.name = "3ware_compat_info",
|
||||
.mode = S_IRUSR,
|
||||
},
|
||||
.size = 0,
|
||||
.read = twl_sysfs_compat_info
|
||||
.read_new = twl_sysfs_compat_info
|
||||
};
|
||||
|
||||
/* Show some statistics about the card */
|
||||
|
||||
Reference in New Issue
Block a user