From: Steve Wise <swise@opengridcomputing.com>
Date: Thu, 1 Mar 2018 13:58:20 -0800
Subject: mlx4_ib: zero out struct ib_pd when allocating
Patch-mainline: v4.17-rc1
Git-commit: 5292443431fff5ba20f1b48985d382dd824016eb
References: bsc#1103988 FATE#326003
Zero out the fields of the struct ib_pd for user mode pds so that
users querying pds via nldev will not get garbage. For simplicity,
use kzalloc() to allocate the mlx4_ib_pd struct.
Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
drivers/infiniband/hw/mlx4/main.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1330,7 +1330,7 @@ static struct ib_pd *mlx4_ib_alloc_pd(st
struct mlx4_ib_pd *pd;
int err;
- pd = kmalloc(sizeof *pd, GFP_KERNEL);
+ pd = kzalloc(sizeof(*pd), GFP_KERNEL);
if (!pd)
return ERR_PTR(-ENOMEM);
@@ -1346,7 +1346,6 @@ static struct ib_pd *mlx4_ib_alloc_pd(st
kfree(pd);
return ERR_PTR(-EFAULT);
}
-
return &pd->ibpd;
}