RDMA: Provide safe ib_alloc_device() function
All callers to ib_alloc_device() provide a larger size than struct ib_device and rely on the fact that struct ib_device is embedded in their driver specific structure as the first member. Provide a safer variant of ib_alloc_device() that checks and enforces this approach to make sure the drivers are using it right. Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:

committed by
Jason Gunthorpe

parent
e5c1bb47cc
commit
459cc69fa4
@@ -555,7 +555,7 @@ struct rxe_dev *rxe_net_add(struct net_device *ndev)
|
||||
int err;
|
||||
struct rxe_dev *rxe = NULL;
|
||||
|
||||
rxe = (struct rxe_dev *)ib_alloc_device(sizeof(*rxe));
|
||||
rxe = ib_alloc_device(rxe_dev, ib_dev);
|
||||
if (!rxe)
|
||||
return NULL;
|
||||
|
||||
|
Reference in New Issue
Block a user