[PATCH 3/3] cmd: pxe: use strdup to copy config

Patrick Delaunay patrick.delaunay at foss.st.com
Fri Oct 28 11:01:20 CEST 2022


Replace malloc and strcpy by strdup in
function parse_label_kernel.

Signed-off-by: Patrick Delaunay <patrick.delaunay at foss.st.com>
---

 boot/pxe_utils.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 756b201eda91..84e63c5cb85f 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -1180,11 +1180,10 @@ static int parse_label_kernel(char **c, struct pxe_label *label)
 	if (!s)
 		return 1;
 
-	label->config = malloc(strlen(s) + 1);
+	label->config = strdup(s);
 	if (!label->config)
 		return -ENOMEM;
 
-	strcpy(label->config, s);
 	*s = 0;
 
 	return 1;
-- 
2.25.1



More information about the U-Boot mailing list