mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
zorro: 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> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> Link: https://lore.kernel.org/20241216-sysfs-const-bin_attr-zorro-v1-1-220a38d49507@weissschuh.net Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
This commit is contained in:
committed by
Geert Uytterhoeven
parent
f6031436a2
commit
738fa3feb2
@@ -81,7 +81,7 @@ static struct attribute *zorro_device_attrs[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static ssize_t zorro_read_config(struct file *filp, struct kobject *kobj,
|
static ssize_t zorro_read_config(struct file *filp, struct kobject *kobj,
|
||||||
struct bin_attribute *bin_attr,
|
const struct bin_attribute *bin_attr,
|
||||||
char *buf, loff_t off, size_t count)
|
char *buf, loff_t off, size_t count)
|
||||||
{
|
{
|
||||||
struct zorro_dev *z = to_zorro_dev(kobj_to_dev(kobj));
|
struct zorro_dev *z = to_zorro_dev(kobj_to_dev(kobj));
|
||||||
@@ -98,23 +98,23 @@ static ssize_t zorro_read_config(struct file *filp, struct kobject *kobj,
|
|||||||
return memory_read_from_buffer(buf, count, &off, &cd, sizeof(cd));
|
return memory_read_from_buffer(buf, count, &off, &cd, sizeof(cd));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct bin_attribute zorro_config_attr = {
|
static const struct bin_attribute zorro_config_attr = {
|
||||||
.attr = {
|
.attr = {
|
||||||
.name = "config",
|
.name = "config",
|
||||||
.mode = S_IRUGO,
|
.mode = S_IRUGO,
|
||||||
},
|
},
|
||||||
.size = sizeof(struct ConfigDev),
|
.size = sizeof(struct ConfigDev),
|
||||||
.read = zorro_read_config,
|
.read_new = zorro_read_config,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct bin_attribute *zorro_device_bin_attrs[] = {
|
static const struct bin_attribute *const zorro_device_bin_attrs[] = {
|
||||||
&zorro_config_attr,
|
&zorro_config_attr,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct attribute_group zorro_device_attr_group = {
|
static const struct attribute_group zorro_device_attr_group = {
|
||||||
.attrs = zorro_device_attrs,
|
.attrs = zorro_device_attrs,
|
||||||
.bin_attrs = zorro_device_bin_attrs,
|
.bin_attrs_new = zorro_device_bin_attrs,
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct attribute_group *zorro_device_attribute_groups[] = {
|
const struct attribute_group *zorro_device_attribute_groups[] = {
|
||||||
|
|||||||
Reference in New Issue
Block a user