
From: Rikard Falkeborn <rikard.falkeborn@gmail.com> mainline inclusion from mainline-v5.14-rc1 commit c32dc04059c79ddb4f7cff94ad5de6e92ea2218d category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I81XCK Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- The attribute_group structs are never modified, they're only passed to sysfs_create_group() and sysfs_remove_group(). Make them const to allow the compiler to put them in read-only memory. Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com> Signed-off-by: Song Liu <song@kernel.org> Signed-off-by: Li Nan <linan122@huawei.com> --- drivers/md/md.h | 4 ++-- drivers/md/md-bitmap.c | 2 +- drivers/md/md.c | 6 +++--- drivers/md/raid5.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/md/md.h b/drivers/md/md.h index 845ccd842975..72e9f31c3ef9 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -500,7 +500,7 @@ struct mddev { atomic_t max_corr_read_errors; /* max read retries */ struct list_head all_mddevs; - struct attribute_group *to_remove; + const struct attribute_group *to_remove; struct bio_set bio_set; struct bio_set sync_set; /* for sync operations like @@ -637,7 +637,7 @@ struct md_sysfs_entry { ssize_t (*show)(struct mddev *, char *); ssize_t (*store)(struct mddev *, const char *, size_t); }; -extern struct attribute_group md_bitmap_group; +extern const struct attribute_group md_bitmap_group; static inline struct kernfs_node *sysfs_get_dirent_safe(struct kernfs_node *sd, char *name) { diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index e842beb89858..895bbb512135 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -2637,7 +2637,7 @@ static struct attribute *md_bitmap_attrs[] = { &max_backlog_used.attr, NULL }; -struct attribute_group md_bitmap_group = { +const struct attribute_group md_bitmap_group = { .name = "bitmap", .attrs = md_bitmap_attrs, }; diff --git a/drivers/md/md.c b/drivers/md/md.c index 0cf90ed4cfe3..b841b6ed379b 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -800,7 +800,7 @@ static struct mddev *mddev_alloc(dev_t unit) return ERR_PTR(error); } -static struct attribute_group md_redundancy_group; +static const struct attribute_group md_redundancy_group; void mddev_unlock(struct mddev *mddev) { @@ -817,7 +817,7 @@ void mddev_unlock(struct mddev *mddev) * test it under the same mutex to ensure its correct value * is seen. */ - struct attribute_group *to_remove = mddev->to_remove; + const struct attribute_group *to_remove = mddev->to_remove; mddev->to_remove = NULL; mddev->sysfs_active = 1; mutex_unlock(&mddev->reconfig_mutex); @@ -5608,7 +5608,7 @@ static struct attribute *md_redundancy_attrs[] = { &md_degraded.attr, NULL, }; -static struct attribute_group md_redundancy_group = { +static const struct attribute_group md_redundancy_group = { .name = NULL, .attrs = md_redundancy_attrs, }; diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index bef14340f9c1..7e78499aa9d3 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -6950,7 +6950,7 @@ static struct attribute *raid5_attrs[] = { &ppl_write_hint.attr, NULL, }; -static struct attribute_group raid5_attrs_group = { +static const struct attribute_group raid5_attrs_group = { .name = NULL, .attrs = raid5_attrs, }; -- 2.39.2