mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
misc: sram: 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/20241221-sysfs-const-bin_attr-misc-drivers-v2-3-ba5e79fe8771@weissschuh.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e47e0e7ed0
commit
c3b8c358c4
1 changed files with 4 additions and 4 deletions
|
@ -23,7 +23,7 @@
|
||||||
#define SRAM_GRANULARITY 32
|
#define SRAM_GRANULARITY 32
|
||||||
|
|
||||||
static ssize_t sram_read(struct file *filp, struct kobject *kobj,
|
static ssize_t sram_read(struct file *filp, struct kobject *kobj,
|
||||||
struct bin_attribute *attr,
|
const struct bin_attribute *attr,
|
||||||
char *buf, loff_t pos, size_t count)
|
char *buf, loff_t pos, size_t count)
|
||||||
{
|
{
|
||||||
struct sram_partition *part;
|
struct sram_partition *part;
|
||||||
|
@ -38,7 +38,7 @@ static ssize_t sram_read(struct file *filp, struct kobject *kobj,
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t sram_write(struct file *filp, struct kobject *kobj,
|
static ssize_t sram_write(struct file *filp, struct kobject *kobj,
|
||||||
struct bin_attribute *attr,
|
const struct bin_attribute *attr,
|
||||||
char *buf, loff_t pos, size_t count)
|
char *buf, loff_t pos, size_t count)
|
||||||
{
|
{
|
||||||
struct sram_partition *part;
|
struct sram_partition *part;
|
||||||
|
@ -83,8 +83,8 @@ static int sram_add_export(struct sram_dev *sram, struct sram_reserve *block,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
part->battr.attr.mode = S_IRUSR | S_IWUSR;
|
part->battr.attr.mode = S_IRUSR | S_IWUSR;
|
||||||
part->battr.read = sram_read;
|
part->battr.read_new = sram_read;
|
||||||
part->battr.write = sram_write;
|
part->battr.write_new = sram_write;
|
||||||
part->battr.size = block->size;
|
part->battr.size = block->size;
|
||||||
|
|
||||||
return device_create_bin_file(sram->dev, &part->battr);
|
return device_create_bin_file(sram->dev, &part->battr);
|
||||||
|
|
Loading…
Add table
Reference in a new issue