public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: dillon.minfei at gmail.com <dillon.minfei@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v5 6/7] ram: stm32: fix strsep failed on read only memory
Date: Fri,  9 Apr 2021 15:28:45 +0800	[thread overview]
Message-ID: <1617953326-3110-7-git-send-email-dillon.minfei@gmail.com> (raw)
In-Reply-To: <1617953326-3110-1-git-send-email-dillon.minfei@gmail.com>

From: dillon min <dillon.minfei@gmail.com>

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>
---
v5: no changes

 drivers/ram/stm32_sdram.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/ram/stm32_sdram.c b/drivers/ram/stm32_sdram.c
index 540ad85..3e25cc7 100644
--- a/drivers/ram/stm32_sdram.c
+++ b/drivers/ram/stm32_sdram.c
@@ -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");
-- 
2.7.4

  parent reply	other threads:[~2021-04-09  7:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-09  7:28 [PATCH v5 0/7] Add rt-thread art-pi board support dillon.minfei at gmail.com
2021-04-09  7:28 ` [PATCH v5 1/7] ARM: dts: stm32: split sdram pin & timing parameter into specific board dts dillon.minfei at gmail.com
2021-04-09  9:46   ` Patrice CHOTARD
2021-04-09  7:28 ` [PATCH v5 2/7] ARM: dts: stm32: introduce stm32h7-pinctrl.dtsi to support stm32h750 dillon.minfei at gmail.com
2021-04-09  9:47   ` Patrice CHOTARD
2021-04-09  7:28 ` [PATCH v5 3/7] ARM: dts: stm32: add new instances for stm32h743 MCU dillon.minfei at gmail.com
2021-04-09  9:47   ` Patrice CHOTARD
2021-04-09  7:28 ` [PATCH v5 4/7] ARM: dts: stm32: fix i2c node typo in stm32h743, update dmamux1 register dillon.minfei at gmail.com
2021-04-09  9:47   ` Patrice CHOTARD
2021-04-09  7:28 ` [PATCH v5 5/7] ARM: dts: stm32: add support for art-pi board based on stm32h750xbh6 dillon.minfei at gmail.com
2021-04-09  9:47   ` Patrice CHOTARD
2021-04-09  7:28 ` dillon.minfei at gmail.com [this message]
2021-04-09  9:47   ` [PATCH v5 6/7] ram: stm32: fix strsep failed on read only memory Patrice CHOTARD
2021-04-09  7:28 ` [PATCH v5 7/7] board: Add rt-thread art-pi board support dillon.minfei at gmail.com
2021-04-09  9:47   ` Patrice CHOTARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1617953326-3110-7-git-send-email-dillon.minfei@gmail.com \
    --to=dillon.minfei@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox