[PATCH] RDMA/cma: Constify struct configfs_item_operations and configfs_group_operations

Christophe JAILLET posted 1 patch 1 week, 1 day ago
drivers/infiniband/core/cma_configfs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] RDMA/cma: Constify struct configfs_item_operations and configfs_group_operations
Posted by Christophe JAILLET 1 week, 1 day ago
'struct configfs_item_operations' and 'configfs_group_operations' 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:
Before:
======
   text	   data	    bss	    dec	    hex	filename
   6677	   2776	     64	   9517	   252d	drivers/infiniband/core/cma_configfs.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
   6901	   2552	     64	   9517	   252d	drivers/infiniband/core/cma_configfs.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/infiniband/core/cma_configfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/core/cma_configfs.c b/drivers/infiniband/core/cma_configfs.c
index 819927ce4f0e..891e52afb8f4 100644
--- a/drivers/infiniband/core/cma_configfs.c
+++ b/drivers/infiniband/core/cma_configfs.c
@@ -255,7 +255,7 @@ static void release_cma_ports_group(struct config_item  *item)
 	cma_dev_group->ports = NULL;
 };
 
-static struct configfs_item_operations cma_ports_item_ops = {
+static const struct configfs_item_operations cma_ports_item_ops = {
 	.release = release_cma_ports_group
 };
 
@@ -264,7 +264,7 @@ static const struct config_item_type cma_ports_group_type = {
 	.ct_owner	= THIS_MODULE
 };
 
-static struct configfs_item_operations cma_device_item_ops = {
+static const struct configfs_item_operations cma_device_item_ops = {
 	.release = release_cma_dev
 };
 
@@ -327,7 +327,7 @@ static void drop_cma_dev(struct config_group *cgroup, struct config_item *item)
 	config_item_put(item);
 }
 
-static struct configfs_group_operations cma_subsys_group_ops = {
+static const struct configfs_group_operations cma_subsys_group_ops = {
 	.make_group	= make_cma_dev,
 	.drop_item	= drop_cma_dev,
 };
-- 
2.54.0
Re: [PATCH] RDMA/cma: Constify struct configfs_item_operations and configfs_group_operations
Posted by Leon Romanovsky 1 week ago
On Sat, 16 May 2026 11:17:47 +0200, Christophe JAILLET wrote:
> 'struct configfs_item_operations' and 'configfs_group_operations' 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.
> 
> [...]

Applied, thanks!

[1/1] RDMA/cma: Constify struct configfs_item_operations and configfs_group_operations
      https://git.kernel.org/rdma/rdma/c/7b2e9a338a5875

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>