Skip to content

Commit d8b73ce

Browse files
tititiou36Pratyush Yadav
authored andcommitted
mtd: spi-nor: Constify struct spi_nor_fixups
'struct spi_nor_fixups' are not modified in this driver. Constifying these structures moves some data to a read-only section, so increases overall security, especially when the structure holds some function pointers. On a x86_64, with allmodconfig, as an example: Before: ====== text data bss dec hex filename 23304 13168 0 36472 8e78 drivers/mtd/spi-nor/micron-st.o After: ===== text data bss dec hex filename 23560 12912 0 36472 8e78 drivers/mtd/spi-nor/micron-st.o Signed-off-by: Christophe JAILLET <[email protected]> Acked-by: Pratyush Yadav <[email protected]> Signed-off-by: Pratyush Yadav <[email protected]> Link: https://lore.kernel.org/r/aa641732ba707ce3690217825c3ca7373ffde4f9.1748191985.git.christophe.jaillet@wanadoo.fr
1 parent 19272b3 commit d8b73ce

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

drivers/mtd/spi-nor/micron-st.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ static int mt25qu512a_post_bfpt_fixup(struct spi_nor *nor,
189189
return 0;
190190
}
191191

192-
static struct spi_nor_fixups mt25qu512a_fixups = {
192+
static const struct spi_nor_fixups mt25qu512a_fixups = {
193193
.post_bfpt = mt25qu512a_post_bfpt_fixup,
194194
};
195195

@@ -225,15 +225,15 @@ static int st_nor_two_die_late_init(struct spi_nor *nor)
225225
return spi_nor_set_4byte_addr_mode(nor, true);
226226
}
227227

228-
static struct spi_nor_fixups n25q00_fixups = {
228+
static const struct spi_nor_fixups n25q00_fixups = {
229229
.late_init = st_nor_four_die_late_init,
230230
};
231231

232-
static struct spi_nor_fixups mt25q01_fixups = {
232+
static const struct spi_nor_fixups mt25q01_fixups = {
233233
.late_init = st_nor_two_die_late_init,
234234
};
235235

236-
static struct spi_nor_fixups mt25q02_fixups = {
236+
static const struct spi_nor_fixups mt25q02_fixups = {
237237
.late_init = st_nor_four_die_late_init,
238238
};
239239

drivers/mtd/spi-nor/spansion.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ static int s25fs256t_late_init(struct spi_nor *nor)
578578
return 0;
579579
}
580580

581-
static struct spi_nor_fixups s25fs256t_fixups = {
581+
static const struct spi_nor_fixups s25fs256t_fixups = {
582582
.post_bfpt = s25fs256t_post_bfpt_fixup,
583583
.post_sfdp = s25fs256t_post_sfdp_fixup,
584584
.late_init = s25fs256t_late_init,
@@ -650,7 +650,7 @@ static int s25hx_t_late_init(struct spi_nor *nor)
650650
return 0;
651651
}
652652

653-
static struct spi_nor_fixups s25hx_t_fixups = {
653+
static const struct spi_nor_fixups s25hx_t_fixups = {
654654
.post_bfpt = s25hx_t_post_bfpt_fixup,
655655
.post_sfdp = s25hx_t_post_sfdp_fixup,
656656
.late_init = s25hx_t_late_init,

0 commit comments

Comments
 (0)