Skip to content

Commit 5292443

Browse files
Steve Wisedledford
authored andcommitted
mlx4_ib: zero out struct ib_pd when allocating
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 <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent fccec5b commit 5292443

File tree

1 file changed

+1
-2
lines changed
  • drivers/infiniband/hw/mlx4

1 file changed

+1
-2
lines changed

drivers/infiniband/hw/mlx4/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ static struct ib_pd *mlx4_ib_alloc_pd(struct ib_device *ibdev,
13271327
struct mlx4_ib_pd *pd;
13281328
int err;
13291329

1330-
pd = kmalloc(sizeof *pd, GFP_KERNEL);
1330+
pd = kzalloc(sizeof(*pd), GFP_KERNEL);
13311331
if (!pd)
13321332
return ERR_PTR(-ENOMEM);
13331333

@@ -1343,7 +1343,6 @@ static struct ib_pd *mlx4_ib_alloc_pd(struct ib_device *ibdev,
13431343
kfree(pd);
13441344
return ERR_PTR(-EFAULT);
13451345
}
1346-
13471346
return &pd->ibpd;
13481347
}
13491348

0 commit comments

Comments
 (0)