Skip to contentSkip to conversation

net: tftp: Remove tftp_init_load_addr error path

PATCH In review Leonard Anderweit 2 participants 2 messages Nov 20, 2025 Networking

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: tftp: Remove tftp_init_load_addr error path

tftp_init_load_addr() always returns 0 since commit af45c84871e4 ("tftp:
rework the logic to validate the load address"), so we don't need to check if it failed and can remove the error handling.
Also change tftp_init_load_addr() to static void since the return value is now unused.

---
v2: change tftp_init_load_addr() to static void as suggested by Yannic

---
 net/tftp.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)
net/tftp.c +3 -15
index 1760877107fa..3b0f4cd2006e 100644
@@ -714,10 +714,9 @@ static void tftp_timeout_handler(void)
 	}
 }
 
-static int tftp_init_load_addr(void)
+static void tftp_init_load_addr(void)
 {
 	tftp_load_addr = image_load_addr;
-	return 0;
 }
 
 static int saved_tftp_block_size_option;
@@ -901,13 +900,7 @@ void tftp_start(enum proto_t protocol)
 	} else
 #endif
 	{
-		if (tftp_init_load_addr()) {
-			eth_halt();
-			net_set_state(NETLOOP_FAIL);
-			puts("\nTFTP error: ");
-			puts("trying to overwrite reserved memory...\n");
-			return;
-		}
+		tftp_init_load_addr();
 		printf("Load address: 0x%lx\n", tftp_load_addr);
 		puts("Loading: *\b");
 		tftp_state = STATE_SEND_RRQ;
@@ -953,12 +946,7 @@ void tftp_start_server(void)
 {
 	tftp_filename[0] = 0;
 
-	if (tftp_init_load_addr()) {
-		eth_halt();
-		net_set_state(NETLOOP_FAIL);
-		puts("\nTFTP error: trying to overwrite reserved memory...\n");
-		return;
-	}
+	tftp_init_load_addr();
 	printf("Using %s device\n", eth_get_name());
 	printf("Listening for TFTP transfer on %pI4\n", &net_ip);
 	printf("Load address: 0x%lx\n", tftp_load_addr);
Signature · 1 line
2.43.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Leonard Anderweit

tftp_init_load_addr() always returns 0 since commit af45c84871e4 ("tftp:
rework the logic to validate the load address"), so we don't need to check if it failed and can remove the error handling. Also change tftp_init_load_addr() to static void since the return value
is now unused.

Quoted 54 lines

---
v2: change tftp_init_load_addr() to static void as suggested by Yannic
---
 net/tftp.c | 18 +++---------------

 1 file changed, 3 insertions(+), 15 deletions(-)
net/tftp.c +0 -0
index 1760877107fa..3b0f4cd2006e 100644
@@ -714,10 +714,9 @@ static void tftp_timeout_handler(void)
  	}
  }

net/tftp.c +1 -1
-static int tftp_init_load_addr(void)
+static void tftp_init_load_addr(void)

 {
  tftp_load_addr = image_load_addr;

net/tftp.c +0 -1
-	return 0;

 }

 static int saved_tftp_block_size_option;

net/tftp.c +1 -7
@@ -901,13 +900,7 @@ void tftp_start(enum proto_t protocol)
  	} else
  #endif
  	{
-		if (tftp_init_load_addr()) {
-			eth_halt();
-			net_set_state(NETLOOP_FAIL);
-			puts("\nTFTP error: ");
-			puts("trying to overwrite reserved
 memory...\n");
-			return;
-		}
+		tftp_init_load_addr();
  		printf("Load address: 0x%lx\n", tftp_load_addr);
  		puts("Loading: *\b");

  tftp_state = STATE_SEND_RRQ;

net/tftp.c +0 -0
@@ -953,12 +946,7 @@ void tftp_start_server(void)
  {
  	tftp_filename[0] = 0;

net/tftp.c +0 -4
-	if (tftp_init_load_addr()) {
-		eth_halt();
-		net_set_state(NETLOOP_FAIL);
-		puts("\nTFTP error: trying to overwrite reserved

memory...\n");

net/tftp.c +1 -2
-		return;
-	}
+	tftp_init_load_addr();

  printf("Using %s device\n", eth_get_name()); printf("Listening for TFTP transfer on %pI4\n", &net_ip); printf("Load address: 0x%lx\n", tftp_load_addr);