mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 08:42:12 +02:00
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>
This commit is contained in:
7
env/sf.c
vendored
7
env/sf.c
vendored
@@ -53,16 +53,15 @@ static int setup_flash_device(void)
|
|||||||
|
|
||||||
env_flash = dev_get_uclass_priv(new);
|
env_flash = dev_get_uclass_priv(new);
|
||||||
#else
|
#else
|
||||||
|
if (env_flash)
|
||||||
|
spi_flash_free(env_flash);
|
||||||
|
|
||||||
if (!env_flash) {
|
env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
|
||||||
env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS,
|
|
||||||
CONFIG_ENV_SPI_CS,
|
|
||||||
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
|
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
|
||||||
if (!env_flash) {
|
if (!env_flash) {
|
||||||
env_set_default("spi_flash_probe() failed", 0);
|
env_set_default("spi_flash_probe() failed", 0);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user