[PATCH] peci: npcm: Constify struct peci_controller_ops​

Christophe JAILLET christophe.jaillet at wanadoo.fr
Sat Sep 7 17:00:04 AEST 2024


'struct peci_controller_ops' is not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
   8003	    784	     48	   8835	   2283	drivers/peci/controller/peci-npcm.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
   8003	    776	     48	   8827	   227b	drivers/peci/controller/peci-npcm.o

Signed-off-by: Christophe JAILLET <christophe.jaillet at wanadoo.fr>
---
Compile tested only
---
 drivers/peci/controller/peci-npcm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/peci/controller/peci-npcm.c b/drivers/peci/controller/peci-npcm.c
index ec613d35c796..fa91be58f6f3 100644
--- a/drivers/peci/controller/peci-npcm.c
+++ b/drivers/peci/controller/peci-npcm.c
@@ -224,7 +224,7 @@ static const struct regmap_config npcm_peci_regmap_config = {
 	.fast_io = true,
 };
 
-static struct peci_controller_ops npcm_ops = {
+static const struct peci_controller_ops npcm_ops = {
 	.xfer = npcm_peci_xfer,
 };
 
-- 
2.46.0



More information about the openbmc mailing list