Skip to contentSkip to conversation

nvmet: pci-epf: Constify struct pci_epf_ops

PATCH Applied Christophe JAILLET 3 participants 3 messages Oct 31 – Nov 3

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvmet: pci-epf: Constify struct pci_epf_ops

'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

---
Compile tested only.

---
 drivers/nvme/target/pci-epf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/pci-epf.c +1 -1
index c683450df422..377cd428fa65 100644
@@ -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,
Signature · 1 line
2.56.0
maintainer Applied
#2 lore raw
In reply to Christophe JAILLET
Quoted 12 lines · Christophe JAILLET

'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

Quoted 4 lines

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

Thanks, applied to nvme-7.4.