From 5b6fafb3f51abd8cbce5d74e3edf364734d72379 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 30 Jun 2016 17:49:53 -0600 Subject: [PATCH] Several MTD FLASH drivers nullify the freed 'priv' structure and failed to return NULL as stated in the comments. Result, will operate on a NULL pointer later. Noted by David Sidrane. --- drivers/mtd/at25.c | 2 +- drivers/mtd/is25xp.c | 3 +-- drivers/mtd/m25px.c | 2 +- drivers/mtd/ramtron.c | 2 +- drivers/mtd/sst25.c | 2 +- drivers/mtd/sst25xx.c | 2 +- drivers/mtd/sst26.c | 2 +- drivers/mtd/w25.c | 2 +- 8 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/at25.c b/drivers/mtd/at25.c index efc2e355a7..777ff3877f 100644 --- a/drivers/mtd/at25.c +++ b/drivers/mtd/at25.c @@ -673,7 +673,7 @@ FAR struct mtd_dev_s *at25_initialize(FAR struct spi_dev_s *dev) ferr("ERROR: Unrecognized\n"); kmm_free(priv); - priv = NULL; + return NULL; } else { diff --git a/drivers/mtd/is25xp.c b/drivers/mtd/is25xp.c index 2228f760b0..55b677b38a 100644 --- a/drivers/mtd/is25xp.c +++ b/drivers/mtd/is25xp.c @@ -978,7 +978,7 @@ FAR struct mtd_dev_s *is25xp_initialize(FAR struct spi_dev_s *dev) ferr("ERROR: Unrecognized\n"); kmm_free(priv); - priv = NULL; + return NULL; } else { @@ -999,4 +999,3 @@ FAR struct mtd_dev_s *is25xp_initialize(FAR struct spi_dev_s *dev) finfo("Return %p\n", priv); return (FAR struct mtd_dev_s *)priv; } - diff --git a/drivers/mtd/m25px.c b/drivers/mtd/m25px.c index eb2cade8ee..4402995afb 100644 --- a/drivers/mtd/m25px.c +++ b/drivers/mtd/m25px.c @@ -1033,7 +1033,7 @@ FAR struct mtd_dev_s *m25p_initialize(FAR struct spi_dev_s *dev) ferr("ERROR: Unrecognized\n"); kmm_free(priv); - priv = NULL; + return NULL; } } diff --git a/drivers/mtd/ramtron.c b/drivers/mtd/ramtron.c index a81469f92e..0152475b98 100644 --- a/drivers/mtd/ramtron.c +++ b/drivers/mtd/ramtron.c @@ -826,7 +826,7 @@ FAR struct mtd_dev_s *ramtron_initialize(FAR struct spi_dev_s *dev) /* Unrecognized! Discard all of that work we just did and return NULL */ kmm_free(priv); - priv = NULL; + return NULL; } } diff --git a/drivers/mtd/sst25.c b/drivers/mtd/sst25.c index 89d21324aa..8da5778d84 100644 --- a/drivers/mtd/sst25.c +++ b/drivers/mtd/sst25.c @@ -1208,7 +1208,7 @@ FAR struct mtd_dev_s *sst25_initialize(FAR struct spi_dev_s *dev) ferr("ERROR: Unrecognized\n"); kmm_free(priv); - priv = NULL; + return NULL; } else { diff --git a/drivers/mtd/sst25xx.c b/drivers/mtd/sst25xx.c index 4d30be50bb..9f883483af 100644 --- a/drivers/mtd/sst25xx.c +++ b/drivers/mtd/sst25xx.c @@ -956,7 +956,7 @@ FAR struct mtd_dev_s *sst25xx_initialize(FAR struct spi_dev_s *dev) ferr("ERROR: Unrecognized\n"); kmm_free(priv); - priv = NULL; + return NULL; } else { diff --git a/drivers/mtd/sst26.c b/drivers/mtd/sst26.c index 91eb045fcf..51888da063 100644 --- a/drivers/mtd/sst26.c +++ b/drivers/mtd/sst26.c @@ -934,7 +934,7 @@ FAR struct mtd_dev_s *sst26_initialize_spi(FAR struct spi_dev_s *dev) ssterr("ERROR: Unrecognized\n"); kmm_free(priv); - priv = NULL; + return NULL; } else { diff --git a/drivers/mtd/w25.c b/drivers/mtd/w25.c index 3559f8d6a5..da015a8c42 100644 --- a/drivers/mtd/w25.c +++ b/drivers/mtd/w25.c @@ -1258,7 +1258,7 @@ FAR struct mtd_dev_s *w25_initialize(FAR struct spi_dev_s *spi) ferr("ERROR: Unrecognized\n"); kmm_free(priv); - priv = NULL; + return NULL; } else {