diff options
author | Feras Daoud <ferasda@mellanox.com> | 2017-06-14 09:59:09 +0300 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2017-09-15 18:30:11 +0100 |
commit | ae5212ab18d9691212721243938cb9cd03293adb (patch) | |
tree | c9aea7565188a18f93c8f4233ecc7b40bd60d611 | |
parent | 6e850c96ffa09cc449737e864194ed46f64b4955 (diff) | |
download | linux-stable-ae5212ab18d9691212721243938cb9cd03293adb.tar.gz linux-stable-ae5212ab18d9691212721243938cb9cd03293adb.tar.bz2 linux-stable-ae5212ab18d9691212721243938cb9cd03293adb.zip |
IB/ipoib: Fix memory leak in create child syscall
commit 4542d66bb26f2d021c70a78e46f183c6675fc4c9 upstream.
The flow of creating a new child goes through ipoib_vlan_add
which allocates a new interface and checks the rtnl_lock.
If the lock is taken, restart_syscall will be called to restart
the system call again. In this case we are not releasing the
already allocated interface, causing a leak.
Fixes: 9baa0b036410 ("IB/ipoib: Add rtnl_link_ops support")
Signed-off-by: Feras Daoud <ferasda@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c index 4c83a970e7f3..946a1cceffd9 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c @@ -133,13 +133,14 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey) snprintf(intf_name, sizeof intf_name, "%s.%04x", ppriv->dev->name, pkey); - priv = ipoib_intf_alloc(intf_name); - if (!priv) - return -ENOMEM; if (!rtnl_trylock()) return restart_syscall(); + priv = ipoib_intf_alloc(intf_name); + if (!priv) + return -ENOMEM; + down_write(&ppriv->vlan_rwsem); /* |