Skip to content

Commit be16b46

Browse files
t-8chkuba-moo
authored andcommitted
ptp: ocp: 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 <[email protected]> Reviewed-by: Vadim Fedorenko <[email protected]> Link: https://patch.msgid.link/20241222-sysfs-const-bin_attr-ptp-v1-1-5c1f3ee246fb@weissschuh.net Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c83ca5a commit be16b46

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/ptp/ptp_ocp.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3692,7 +3692,7 @@ DEVICE_FREQ_GROUP(freq4, 3);
36923692

36933693
static ssize_t
36943694
disciplining_config_read(struct file *filp, struct kobject *kobj,
3695-
struct bin_attribute *bin_attr, char *buf,
3695+
const struct bin_attribute *bin_attr, char *buf,
36963696
loff_t off, size_t count)
36973697
{
36983698
struct ptp_ocp *bp = dev_get_drvdata(kobj_to_dev(kobj));
@@ -3727,7 +3727,7 @@ disciplining_config_read(struct file *filp, struct kobject *kobj,
37273727

37283728
static ssize_t
37293729
disciplining_config_write(struct file *filp, struct kobject *kobj,
3730-
struct bin_attribute *bin_attr, char *buf,
3730+
const struct bin_attribute *bin_attr, char *buf,
37313731
loff_t off, size_t count)
37323732
{
37333733
struct ptp_ocp *bp = dev_get_drvdata(kobj_to_dev(kobj));
@@ -3750,11 +3750,11 @@ disciplining_config_write(struct file *filp, struct kobject *kobj,
37503750

37513751
return err;
37523752
}
3753-
static BIN_ATTR_RW(disciplining_config, OCP_ART_CONFIG_SIZE);
3753+
static const BIN_ATTR_RW(disciplining_config, OCP_ART_CONFIG_SIZE);
37543754

37553755
static ssize_t
37563756
temperature_table_read(struct file *filp, struct kobject *kobj,
3757-
struct bin_attribute *bin_attr, char *buf,
3757+
const struct bin_attribute *bin_attr, char *buf,
37583758
loff_t off, size_t count)
37593759
{
37603760
struct ptp_ocp *bp = dev_get_drvdata(kobj_to_dev(kobj));
@@ -3789,7 +3789,7 @@ temperature_table_read(struct file *filp, struct kobject *kobj,
37893789

37903790
static ssize_t
37913791
temperature_table_write(struct file *filp, struct kobject *kobj,
3792-
struct bin_attribute *bin_attr, char *buf,
3792+
const struct bin_attribute *bin_attr, char *buf,
37933793
loff_t off, size_t count)
37943794
{
37953795
struct ptp_ocp *bp = dev_get_drvdata(kobj_to_dev(kobj));
@@ -3812,7 +3812,7 @@ temperature_table_write(struct file *filp, struct kobject *kobj,
38123812

38133813
return err;
38143814
}
3815-
static BIN_ATTR_RW(temperature_table, OCP_ART_TEMP_TABLE_SIZE);
3815+
static const BIN_ATTR_RW(temperature_table, OCP_ART_TEMP_TABLE_SIZE);
38163816

38173817
static struct attribute *fb_timecard_attrs[] = {
38183818
&dev_attr_serialnum.attr,
@@ -3867,15 +3867,15 @@ static struct attribute *art_timecard_attrs[] = {
38673867
NULL,
38683868
};
38693869

3870-
static struct bin_attribute *bin_art_timecard_attrs[] = {
3870+
static const struct bin_attribute *const bin_art_timecard_attrs[] = {
38713871
&bin_attr_disciplining_config,
38723872
&bin_attr_temperature_table,
38733873
NULL,
38743874
};
38753875

38763876
static const struct attribute_group art_timecard_group = {
38773877
.attrs = art_timecard_attrs,
3878-
.bin_attrs = bin_art_timecard_attrs,
3878+
.bin_attrs_new = bin_art_timecard_attrs,
38793879
};
38803880

38813881
static const struct ocp_attr_group art_timecard_groups[] = {

0 commit comments

Comments
 (0)