On 10/07/2026 17:20, Naveen Kumar Chaudhary wrote:
> sntp_loop() allocates a netif via net_lwip_new_netif() and normally
> releases it with net_lwip_remove_netif() before returning. The error
> path taken when no explicit server IP is passed and ntp_server_known()
> is false returns -1 directly without freeing the netif, leaking the
> lwIP netif structure (and its associated state) on every failed
> invocation of the sntp command.
> 
> Call net_lwip_remove_netif(netif) before returning on this path so it
> matches the other exits.
> 
> Signed-off-by: Naveen Kumar Chaudhary <[email protected]>
> ---
>  cmd/lwip/sntp.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/cmd/lwip/sntp.c b/cmd/lwip/sntp.c
> index 608345c873b..a3659c73ce1 100644
> --- a/cmd/lwip/sntp.c
> +++ b/cmd/lwip/sntp.c
> @@ -71,6 +71,7 @@ static int sntp_loop(struct udevice *udev, ip_addr_t *srvip)
>       } else {
>               if (!ntp_server_known()) {
>                       log_err("error: ntpserverip not set\n");
> +                     net_lwip_remove_netif(netif);
>                       return -1;
>               }
>       }

Reviewed-by: Jerome Forissier <[email protected]>

Applied to u-boot-net/for-master. Thanks!

-- 
Jerome

Reply via email to