]> Git Repo - linux.git/commitdiff
spi: fsl-spi: Fix memory leak
authorAxel Lin <[email protected]>
Sun, 30 Mar 2014 08:42:57 +0000 (16:42 +0800)
committerMark Brown <[email protected]>
Mon, 14 Apr 2014 16:18:55 +0000 (17:18 +0100)
mpc8xxx_spi_probe() has set master->cleanup = mpc8xxx_spi_cleanup,
however current code overrides the setting in fsl_spi_probe() and set
master->cleanup = fsl_spi_cleanup.
Thus the memory allocated for cs is not freed anywhere.
Convert to use devm_kzalloc to fix the memory leak.

Signed-off-by: Axel Lin <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
drivers/spi/spi-fsl-spi.c

index b3e7775034dbd1d660b0ece95a197aea8cb24b54..98ccd231bf009bdb1ac48a10ed8324b6620a3c63 100644 (file)
@@ -431,7 +431,7 @@ static int fsl_spi_setup(struct spi_device *spi)
                return -EINVAL;
 
        if (!cs) {
-               cs = kzalloc(sizeof *cs, GFP_KERNEL);
+               cs = devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL);
                if (!cs)
                        return -ENOMEM;
                spi->controller_state = cs;
This page took 0.05928 seconds and 4 git commands to generate.