]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
soc: fsl: dpio: Use after free in dpaa2_dpio_remove()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 4 Feb 2019 14:10:05 +0000 (17:10 +0300)
committerLi Yang <leoyang.li@nxp.com>
Mon, 4 Feb 2019 20:58:49 +0000 (14:58 -0600)
The dpaa2_io_down(priv->io) call frees "priv->io" so I've shifted the
code around a little bit to avoid the use after free.

Fixes: 991e873223e9 ("soc: fsl: dpio: use a cpumask to identify which cpus are unused")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Li Yang <leoyang.li@nxp.com>
drivers/soc/fsl/dpio/dpio-driver.c

index 2d4af32a0dec46bdaec3af3e4bea58cfff6c8d1c..a28799b62d536254350985807c42c277c3fb3d7f 100644 (file)
@@ -220,12 +220,12 @@ static int dpaa2_dpio_remove(struct fsl_mc_device *dpio_dev)
 
        dev = &dpio_dev->dev;
        priv = dev_get_drvdata(dev);
+       cpu = dpaa2_io_get_cpu(priv->io);
 
        dpaa2_io_down(priv->io);
 
        dpio_teardown_irqs(dpio_dev);
 
-       cpu = dpaa2_io_get_cpu(priv->io);
        cpumask_set_cpu(cpu, cpus_unused_mask);
 
        err = dpio_open(dpio_dev->mc_io, 0, dpio_dev->obj_desc.id,