mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 21:39:35 -04:00
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>
This commit is contained in:
committed by
Leon Romanovsky
parent
9eab9eb222
commit
1069f1c821
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ struct ib_umem_dmabuf *ib_umem_dmabuf_get(struct ib_device *device,
|
||||
unsigned long offset,
|
||||
size_t size, int fd,
|
||||
int access,
|
||||
struct dma_buf_attach_ops *ops)
|
||||
const struct dma_buf_attach_ops *ops)
|
||||
{
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user