[PATCH v3 4/6] ram: stm32: fix strsep failed on read only memory
dillon min
dillon.minfei at gmail.com
Wed Mar 31 11:20:04 CEST 2021
On Wed, Mar 31, 2021 at 5:09 PM Patrice CHOTARD
<patrice.chotard at foss.st.com> wrote:
>
> one remark below
>
> On 3/29/21 5:04 AM, dillon.minfei at gmail.com wrote:
> > From: dillon min <dillon.minfei at 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.
> >
> > Fixes: f303aaf ("ram: stm32: add second SDRAM bank management")
> > Signed-off-by: dillon min <dillon.minfei at gmail.com>
> > Reviewed-by: Patrice Chotard <patrice.chotard at foss.st.com>
> > ---
> > v3: 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..da27677 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);
> > + strcpy(_bank_name, bank_name);
>
> strcpy/strncpy usage is to be avoided. Instead use strlcpy()
Agree, will add to next submission.
thanks.
>
> Thanks
>
> > + bank_name = _bank_name;
> > strsep(&bank_name, "@");
> > if (!bank_name) {
> > pr_err("missing sdram bank index");
> >
More information about the U-Boot
mailing list