summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>2026-07-14 10:19:06 +0200
committerLeon Romanovsky <leon@kernel.org>2026-07-15 04:42:06 -0400
commitdcae56cfecc6e17c9aa4e6bb6057d18efadf2132 (patch)
tree1156afe1c39bcb6fddb83b0d85eb9457556fb10c /drivers
parent9eab9eb2225912665fbee5fa13925232fd13881a (diff)
downloadlinux-next-dcae56cfecc6e17c9aa4e6bb6057d18efadf2132.tar.gz
linux-next-dcae56cfecc6e17c9aa4e6bb6057d18efadf2132.zip
RDMA/mlx5: Constify struct ib_frmr_pool_ops and dma_buf_attach_ops
'struct ib_frmr_pool_ops' and 'struct dma_buf_attach_ops' 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. While at it, change a '1' into a 'true' into the mlx5_ib_dmabuf_attach_ops structure. The 'allow_peer2peer' field is a bool and other usages of 'struct dma_buf_attach_ops' prefer using true/false. On a x86_64, with allmodconfig, as an example: Before: ====== text data bss dec hex filename 77631 10392 320 88343 15917 drivers/infiniband/hw/mlx5/mr.o After: ===== text data bss dec hex filename 77759 10264 320 88343 15917 drivers/infiniband/hw/mlx5/mr.o Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://patch.msgid.link/22f2263c04cc94e242cee712e6e6d82b86ac353d.1784017128.git.christophe.jaillet@wanadoo.fr Signed-off-by: Leon Romanovsky <leon@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/hw/mlx5/mr.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index e6b74955d95d..00e13028762a 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -339,7 +339,7 @@ static int mlx5r_build_frmr_key(struct ib_device *device,
return 0;
}
-static struct ib_frmr_pool_ops mlx5r_frmr_pool_ops = {
+static const struct ib_frmr_pool_ops mlx5r_frmr_pool_ops = {
.create_frmrs = mlx5r_create_mkeys,
.destroy_frmrs = mlx5r_destroy_mkeys,
.build_key = mlx5r_build_frmr_key,
@@ -898,8 +898,8 @@ static void mlx5_ib_dmabuf_invalidate_cb(struct dma_buf_attachment *attach)
ib_umem_dmabuf_unmap_pages(umem_dmabuf);
}
-static struct dma_buf_attach_ops mlx5_ib_dmabuf_attach_ops = {
- .allow_peer2peer = 1,
+static const struct dma_buf_attach_ops mlx5_ib_dmabuf_attach_ops = {
+ .allow_peer2peer = true,
.invalidate_mappings = mlx5_ib_dmabuf_invalidate_cb,
};