summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/drivers/spi/dev_spi_flash_sfud.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/components/drivers/spi/dev_spi_flash_sfud.c b/components/drivers/spi/dev_spi_flash_sfud.c
index 7efb6e594b..cb349d1599 100644
--- a/components/drivers/spi/dev_spi_flash_sfud.c
+++ b/components/drivers/spi/dev_spi_flash_sfud.c
@@ -7,6 +7,7 @@
* Date Author Notes
* 2016-09-28 armink first version.
* 2025-10-30 wdfk-prog enable interrupt-safe operations using spinlocks
+ * 2026-11-30 CXSforHPU use rt_strdup() to copy SFUD device names
*/
#include <stdint.h>
@@ -345,8 +346,8 @@ rt_spi_flash_device_t rt_sfud_flash_probe_ex(const char *spi_flash_dev_name, con
rtt_dev = (rt_spi_flash_device_t) rt_malloc(sizeof(struct spi_flash_device));
sfud_dev = (sfud_flash_t) rt_malloc(sizeof(sfud_flash));
- spi_flash_dev_name_bak = (char *) rt_malloc(rt_strlen(spi_flash_dev_name) + 1);
- spi_dev_name_bak = (char *) rt_malloc(rt_strlen(spi_dev_name) + 1);
+ spi_flash_dev_name_bak = rt_strdup(spi_flash_dev_name);
+ spi_dev_name_bak = rt_strdup(spi_dev_name);
if (rtt_dev) {
rt_memset(rtt_dev, 0, sizeof(struct spi_flash_device));
@@ -359,11 +360,6 @@ rt_spi_flash_device_t rt_sfud_flash_probe_ex(const char *spi_flash_dev_name, con
if (rtt_dev && sfud_dev && spi_flash_dev_name_bak && spi_dev_name_bak) {
rt_memset(sfud_dev, 0, sizeof(sfud_flash));
- rt_strncpy(spi_flash_dev_name_bak, spi_flash_dev_name, rt_strlen(spi_flash_dev_name));
- rt_strncpy(spi_dev_name_bak, spi_dev_name, rt_strlen(spi_dev_name));
- /* make string end sign */
- spi_flash_dev_name_bak[rt_strlen(spi_flash_dev_name)] = '\0';
- spi_dev_name_bak[rt_strlen(spi_dev_name)] = '\0';
/* SPI configure */
{
/* RT-Thread SPI device initialize */