]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ram: stm32: fix strsep failed on read only memory
authordillon min <dillon.minfei@gmail.com>
Fri, 9 Apr 2021 07:28:45 +0000 (15:28 +0800)
committerPatrice Chotard <patrice.chotard@foss.st.com>
Fri, 9 Apr 2021 09:53:00 +0000 (11:53 +0200)
strsep will change data from original memory address,
in case the memory is in non-sdram/sram place, will
run into a bug(hang at SDRAM: )

just add a temporary array to store bank_name[] to fix this
bug.

Signed-off-by: dillon min <dillon.minfei@gmail.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
drivers/ram/stm32_sdram.c

index 540ad8513872b95a32d74aa23496ca75a53c2ad1..3e25cc7a01844d1a34856b41929215da4300ccf6 100644 (file)
@@ -268,6 +268,7 @@ static int stm32_fmc_of_to_plat(struct udevice *dev)
        u32 swp_fmc;
        ofnode bank_node;
        char *bank_name;
+       char _bank_name[128] = {0};
        u8 bank = 0;
        int ret;
 
@@ -300,6 +301,8 @@ static int stm32_fmc_of_to_plat(struct udevice *dev)
        dev_for_each_subnode(bank_node, dev) {
                /* extract the bank index from DT */
                bank_name = (char *)ofnode_get_name(bank_node);
+               strlcpy(_bank_name, bank_name, sizeof(_bank_name));
+               bank_name = (char *)_bank_name;
                strsep(&bank_name, "@");
                if (!bank_name) {
                        pr_err("missing sdram bank index");