Skip to contentSkip to conversation

net: lwip: tftp: update image_load_addr after successful transfer

PATCH In review Pranav Sanwal 2 participants 2 messages Mar 26 – Mar 30 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: lwip: tftp: update image_load_addr after successful transfer

do_tftpb() parses the load address into a local variable laddr but never updates the global image_load_addr. Commands that rely on image_load_addr as their default address (e.g. 'bmp info') therefore operate on the wrong address when called without an explicit argument after tftpboot.

Update image_load_addr to laddr only on a successful transfer, so that it accurately reflects where data was actually loaded.

Fixes 4d4d7838127e ("net: lwip: add TFTP support and tftpboot command")
---
 net/lwip/tftp.c | 2 ++
 1 file changed, 2 insertions(+)
net/lwip/tftp.c +2 -0
index 5c3becc68c6..7f3b28b8507 100644
@@ -368,6 +368,8 @@ int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 
 	if (tftp_loop(eth_get_dev(), laddr, fname, srvip, port) < 0)
 		ret = CMD_RET_FAILURE;
+	else
+		image_load_addr = laddr;
 out:
 	if (arg != net_boot_file_name)
 		free(arg);
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Pranav Sanwal

do_tftpb() parses the load address into a local variable laddr but never updates the global image_load_addr. Commands that rely on image_load_addr as their default address (e.g. 'bmp info') therefore operate on the wrong address when called without an explicit argument after tftpboot.

Quoted 8 lines

Update image_load_addr to laddr only on a successful transfer, so that it accurately reflects where data was actually loaded.

Fixes 4d4d7838127e ("net: lwip: add TFTP support and tftpboot command")
---
 net/lwip/tftp.c | 2 ++
 1 file changed, 2 insertions(+)

Added to net-next.

Thanks,

Signature · 1 line
Jerome
Quoted 14 lines
net/lwip/tftp.c +2 -0
index 5c3becc68c6..7f3b28b8507 100644
@@ -368,6 +368,8 @@ int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 
 	if (tftp_loop(eth_get_dev(), laddr, fname, srvip, port) < 0)
 		ret = CMD_RET_FAILURE;
+	else
+		image_load_addr = laddr;
 out:
 	if (arg != net_boot_file_name)
 		free(arg);