瀏覽代碼

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 <swise@opengridcomputing.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Steve Wise 7 年之前
父節點
當前提交
5292443431
共有 1 個文件被更改,包括 1 次插入2 次删除
  1. 1 2
      drivers/infiniband/hw/mlx4/main.c

+ 1 - 2
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;
 	struct mlx4_ib_pd *pd;
 	int err;
 	int err;
 
 
-	pd = kmalloc(sizeof *pd, GFP_KERNEL);
+	pd = kzalloc(sizeof(*pd), GFP_KERNEL);
 	if (!pd)
 	if (!pd)
 		return ERR_PTR(-ENOMEM);
 		return ERR_PTR(-ENOMEM);
 
 
@@ -1343,7 +1343,6 @@ static struct ib_pd *mlx4_ib_alloc_pd(struct ib_device *ibdev,
 			kfree(pd);
 			kfree(pd);
 			return ERR_PTR(-EFAULT);
 			return ERR_PTR(-EFAULT);
 		}
 		}
-
 	return &pd->ibpd;
 	return &pd->ibpd;
 }
 }