[PATCH] ARM: i.MX: phytec-som-imx6: use strdup instead of basprintf

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Feb 20 04:20:04 PST 2024


Using basprintf to duplicate a string violates memory safety if
default_environment_path were to contain a format specifier.

clangd warns about this, so fix this by using strdup instead.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 arch/arm/boards/phytec-som-imx6/board.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boards/phytec-som-imx6/board.c b/arch/arm/boards/phytec-som-imx6/board.c
index bff95221abf3..2db3fa1db8cd 100644
--- a/arch/arm/boards/phytec-som-imx6/board.c
+++ b/arch/arm/boards/phytec-som-imx6/board.c
@@ -231,7 +231,7 @@ static int physom_imx6_probe(struct device *dev)
 		envdev = "SPI NOR flash";
 		break;
 	default:
-		environment_path = basprintf(default_environment_path);
+		environment_path = strdup(default_environment_path);
 		envdev = default_envdev;
 		break;
 	}
-- 
2.39.2




More information about the barebox mailing list