diff options
author | Jagan Teki <jagan@amarulasolutions.com> | 2020-05-13 16:32:42 +0530 |
---|---|---|
committer | Jagan Teki <jagan@amarulasolutions.com> | 2020-06-01 17:55:24 +0530 |
commit | c8cbf1707cba99cfdf1a6a33e03956a5a788183a (patch) | |
tree | 0bee986dd7142840810e82c827da8c272669619b /env | |
parent | da37b539e62604d090fbc5b52246f8e810f2f9a7 (diff) | |
download | u-boot-c8cbf1707cba99cfdf1a6a33e03956a5a788183a.tar.gz |
env: sf: Free the old env_flash
env_flash is a global flash pointer, and the probe would
happen only if env_flash is NULL, but there is no checking
and free the pointer if is not NULL.
So, this patch frees the old env_flash, and get the probed
flash in to env_flash pointer and finally check if is not NULL.
Cc: Simon Glass <sjg@chromium.org>
Cc: Vignesh R <vigneshr@ti.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Diffstat (limited to 'env')
-rw-r--r-- | env/sf.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -53,15 +53,14 @@ static int setup_flash_device(void) env_flash = dev_get_uclass_priv(new); #else + if (env_flash) + spi_flash_free(env_flash); + env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS, + CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE); if (!env_flash) { - env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, - CONFIG_ENV_SPI_CS, - CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE); - if (!env_flash) { - env_set_default("spi_flash_probe() failed", 0); - return -EIO; - } + env_set_default("spi_flash_probe() failed", 0); + return -EIO; } #endif return 0; |