aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mlx4/mad.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2013-02-04 06:22:36 -0500
committerRoland Dreier <roland@purestorage.com>2013-02-15 18:22:26 -0500
commitcab66d1273e6490603cf5256155584d38cecca68 (patch)
tree3c698a4645dd873c0f4ac025b4a4ccb005b3f1af /drivers/infiniband/hw/mlx4/mad.c
parent836dc9e3fbbab0c30aa6e664417225f5c1fb1c39 (diff)
IB/mlx4: Fix bug unwinding on error in mlx4_ib_init_sriov()
We have to decrement "i" before calling mlx4_ib_free_demux_ctx() or we free something that wasn't allocated. That's fine for free_pv_object() but it would lead to a NULL dereference calling mlx4_ib_free_demux_ctx(). The null dereference is because ->tun is NULL when we check: if (!ctx->tun[i]) Also we didn't free ->sriov.demux[0] so it was a small leak. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/hw/mlx4/mad.c')
-rw-r--r--drivers/infiniband/hw/mlx4/mad.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 0a903c129f0a..934792c477bc 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1999,16 +1999,17 @@ int mlx4_ib_init_sriov(struct mlx4_ib_dev *dev)
1999 goto demux_err; 1999 goto demux_err;
2000 err = mlx4_ib_alloc_demux_ctx(dev, &dev->sriov.demux[i], i + 1); 2000 err = mlx4_ib_alloc_demux_ctx(dev, &dev->sriov.demux[i], i + 1);
2001 if (err) 2001 if (err)
2002 goto demux_err; 2002 goto free_pv;
2003 } 2003 }
2004 mlx4_ib_master_tunnels(dev, 1); 2004 mlx4_ib_master_tunnels(dev, 1);
2005 return 0; 2005 return 0;
2006 2006
2007free_pv:
2008 free_pv_object(dev, mlx4_master_func_num(dev->dev), i + 1);
2007demux_err: 2009demux_err:
2008 while (i > 0) { 2010 while (--i >= 0) {
2009 free_pv_object(dev, mlx4_master_func_num(dev->dev), i + 1); 2011 free_pv_object(dev, mlx4_master_func_num(dev->dev), i + 1);
2010 mlx4_ib_free_demux_ctx(&dev->sriov.demux[i]); 2012 mlx4_ib_free_demux_ctx(&dev->sriov.demux[i]);
2011 --i;
2012 } 2013 }
2013 mlx4_ib_device_unregister_sysfs(dev); 2014 mlx4_ib_device_unregister_sysfs(dev);
2014 2015