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

Neil Armstrong neil.armstrong at linaro.org
Fri Oct 28 11:11:31 CEST 2022


On 28/10/2022 11:01, Patrick Delaunay wrote:
> 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;


Reviewed-by: Neil Armstrong <neil.armstrong at linaro.org>



More information about the U-Boot mailing list