Commit 23d70503 authored by Wei Yongjun's avatar Wei Yongjun Committed by Doug Ledford

IB/core: Fix possible memory leak in cma_resolve_iboe_route()

'work' and 'route->path_rec' are malloced in cma_resolve_iboe_route()
and should be freed before leaving from the error handling cases,
otherwise it will cause memory leak.

Fixes: 20029832 ('IB/core: Validate route when we init ah')
Signed-off-by: default avatarWei Yongjun <weiyj.lk@gmail.com>
Reviewed-by: default avatarHaggai Eran <haggaie@mellanox.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 8303f683
...@@ -2462,18 +2462,24 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv) ...@@ -2462,18 +2462,24 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv)
if (addr->dev_addr.bound_dev_if) { if (addr->dev_addr.bound_dev_if) {
ndev = dev_get_by_index(&init_net, addr->dev_addr.bound_dev_if); ndev = dev_get_by_index(&init_net, addr->dev_addr.bound_dev_if);
if (!ndev) if (!ndev) {
return -ENODEV; ret = -ENODEV;
goto err2;
}
if (ndev->flags & IFF_LOOPBACK) { if (ndev->flags & IFF_LOOPBACK) {
dev_put(ndev); dev_put(ndev);
if (!id_priv->id.device->get_netdev) if (!id_priv->id.device->get_netdev) {
return -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto err2;
}
ndev = id_priv->id.device->get_netdev(id_priv->id.device, ndev = id_priv->id.device->get_netdev(id_priv->id.device,
id_priv->id.port_num); id_priv->id.port_num);
if (!ndev) if (!ndev) {
return -ENODEV; ret = -ENODEV;
goto err2;
}
} }
route->path_rec->net = &init_net; route->path_rec->net = &init_net;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment