diff mbox

spi: fsl-spi: Fix memory leak

Message ID 1396168977.21905.6.camel@phoenix (mailing list archive)
State Accepted
Commit 7a40054361162d2f78f332aa868fed137beb7901
Headers show

Commit Message

Axel Lin March 30, 2014, 8:42 a.m. UTC
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 <axel.lin@ingics.com>
---
 drivers/spi/spi-fsl-spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Brown April 1, 2014, 12:31 p.m. UTC | #1
On Sun, Mar 30, 2014 at 04:42:57PM +0800, Axel Lin wrote:
> 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.

Applied, thanks.
diff mbox

Patch

diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index f35488e..9effb91 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -430,7 +430,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;