Commit ab156afd authored by Alex Vesker's avatar Alex Vesker Committed by Doug Ledford

IB/ipoib: Fix memory leaks for child interfaces priv

There is a need to free priv explicitly and not just to release
the device, child priv is freed explicitly on remove flow and this
patch also includes priv free on error flow in P_key creation
and also in add_port.

Fixes: cd565b4b ('IB/IPoIB: Support acceleration options callbacks')
Signed-off-by: default avatarAlex Vesker <valex@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 07d432bb
...@@ -2237,6 +2237,7 @@ static struct net_device *ipoib_add_port(const char *format, ...@@ -2237,6 +2237,7 @@ static struct net_device *ipoib_add_port(const char *format,
device_init_failed: device_init_failed:
free_netdev(priv->dev); free_netdev(priv->dev);
kfree(priv);
alloc_mem_failed: alloc_mem_failed:
return ERR_PTR(result); return ERR_PTR(result);
...@@ -2277,7 +2278,7 @@ static void ipoib_add_one(struct ib_device *device) ...@@ -2277,7 +2278,7 @@ static void ipoib_add_one(struct ib_device *device)
static void ipoib_remove_one(struct ib_device *device, void *client_data) static void ipoib_remove_one(struct ib_device *device, void *client_data)
{ {
struct ipoib_dev_priv *priv, *tmp; struct ipoib_dev_priv *priv, *tmp, *cpriv, *tcpriv;
struct list_head *dev_list = client_data; struct list_head *dev_list = client_data;
if (!dev_list) if (!dev_list)
...@@ -2301,6 +2302,10 @@ static void ipoib_remove_one(struct ib_device *device, void *client_data) ...@@ -2301,6 +2302,10 @@ static void ipoib_remove_one(struct ib_device *device, void *client_data)
unregister_netdev(priv->dev); unregister_netdev(priv->dev);
free_netdev(priv->dev); free_netdev(priv->dev);
list_for_each_entry_safe(cpriv, tcpriv, &priv->child_intfs, list)
kfree(cpriv);
kfree(priv); kfree(priv);
} }
......
...@@ -167,8 +167,10 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey) ...@@ -167,8 +167,10 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
rtnl_unlock(); rtnl_unlock();
if (result) if (result) {
free_netdev(priv->dev); free_netdev(priv->dev);
kfree(priv);
}
return result; return result;
} }
...@@ -209,6 +211,7 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey) ...@@ -209,6 +211,7 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey)
if (dev) { if (dev) {
free_netdev(dev); free_netdev(dev);
kfree(priv);
return 0; return 0;
} }
......
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