Message ID | a25aab61b16a48c334a2b5495c9dc3ed8dd8028d.1520002437.git.swise@opengridcomputing.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
On Thu, Mar 01, 2018 at 01:58:20PM -0800, Steve Wise wrote: > 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> > --- > drivers/infiniband/hw/mlx4/main.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > Thanks, Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 8d2ee93..2e3789f 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -1327,7 +1327,7 @@ static struct ib_pd *mlx4_ib_alloc_pd(struct ib_device *ibdev, 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); @@ -1343,7 +1343,6 @@ static struct ib_pd *mlx4_ib_alloc_pd(struct ib_device *ibdev, kfree(pd); return ERR_PTR(-EFAULT); } - return &pd->ibpd; }
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> --- drivers/infiniband/hw/mlx4/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)