[PATCH] nvmet: pci-epf: Constify struct pci_epf_ops

Christophe JAILLET christophe.jaillet at wanadoo.fr
Sat Oct 31 14:36:43 PDT 2026


'struct pci_epf_ops' is not modified in this driver.

Constifying this structure 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:
Before:
======
   text	   data	    bss	    dec	    hex	filename
  90026	  19680	    768	 110474	  1af8a	drivers/nvme/target/pci-epf.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  90090	  19616	    768	 110474	  1af8a	drivers/nvme/target/pci-epf.o

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

diff --git a/drivers/nvme/target/pci-epf.c b/drivers/nvme/target/pci-epf.c
index c683450df422..377cd428fa65 100644
--- a/drivers/nvme/target/pci-epf.c
+++ b/drivers/nvme/target/pci-epf.c
@@ -2587,7 +2587,7 @@ static const struct pci_epf_device_id nvmet_pci_epf_ids[] = {
 	{},
 };
 
-static struct pci_epf_ops nvmet_pci_epf_ops = {
+static const struct pci_epf_ops nvmet_pci_epf_ops = {
 	.bind	= nvmet_pci_epf_bind,
 	.unbind	= nvmet_pci_epf_unbind,
 	.add_cfs = nvmet_pci_epf_add_cfs,
-- 
2.56.0




More information about the Linux-nvme mailing list