[3.13.y-ckt stable] Patch "spi: fsl-dspi: Fix memory leak" has been added to staging queue

Kamal Mostafa kamal at canonical.com
Thu Mar 19 22:29:23 UTC 2015

This is a note to let you know that I have just added a patch titled

    spi: fsl-dspi: Fix memory leak

to the linux-3.13.y-queue branch of the 3.13.y-ckt extended stable tree 
which can be found at:


This patch is scheduled to be released in version 3.13.11-ckt17.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.13.y-ckt tree, see



>From 3fe440b856e6fa55479a22dd22a5072660dbadbf Mon Sep 17 00:00:00 2001
From: Axel Lin <axel.lin at ingics.com>
Date: Tue, 25 Mar 2014 09:19:05 +0800
Subject: spi: fsl-dspi: Fix memory leak

commit 0e0cd9ea8961b82947a40471080e7968b634820e upstream.

The memory allocated for chip is not freed anywhere.
Convert to use devm_kzalloc to fix the memory leak.

Signed-off-by: Axel Lin <axel.lin at ingics.com>
Signed-off-by: Mark Brown <broonie at linaro.org>
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
 drivers/spi/spi-fsl-dspi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index b8d897c..2279278 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -336,7 +336,8 @@ static int dspi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
 	/* Only alloc on first setup */
 	chip = spi_get_ctldata(spi);
 	if (chip == NULL) {
-		chip = kcalloc(1, sizeof(struct chip_data), GFP_KERNEL);
+		chip = devm_kzalloc(&spi->dev, sizeof(struct chip_data),
+				    GFP_KERNEL);
 		if (!chip)
 			return -ENOMEM;
@@ -347,7 +348,6 @@ static int dspi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
 		fmsz = spi->bits_per_word - 1;
 	} else {
 		pr_err("Invalid wordsize\n");
-		kfree(chip);
 		return -ENODEV;


More information about the kernel-team mailing list