net: mdio-uclass: rename arguments of dm_mdio_phy_connect for clarity
[oweals/u-boot.git] / net / tftp.c
index eca801aa194eb7fb71b5ed8f1de31faaf12f3502..1e3c18ae69c0f975e22383fcdcba18bcee0eec38 100644 (file)
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <command.h>
 #include <efi_loader.h>
+#include <env.h>
 #include <mapmem.h>
 #include <net.h>
 #include <net/tftp.h>
@@ -170,8 +171,13 @@ static inline int store_block(int block, uchar *src, unsigned int len)
                void *ptr;
 
 #ifdef CONFIG_LMB
+               ulong end_addr = tftp_load_addr + tftp_load_size;
+
+               if (!end_addr)
+                       end_addr = ULONG_MAX;
+
                if (store_addr < tftp_load_addr ||
-                   store_addr + len > tftp_load_addr + tftp_load_size) {
+                   store_addr + len > end_addr) {
                        puts("\nTFTP error: ");
                        puts("trying to overwrite reserved memory...\n");
                        return -1;
@@ -606,8 +612,7 @@ static int tftp_init_load_addr(void)
        struct lmb lmb;
        phys_size_t max_size;
 
-       lmb_init_and_reserve(&lmb, gd->bd->bi_dram[0].start,
-                            gd->bd->bi_dram[0].size, (void *)gd->fdt_blob);
+       lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob);
 
        max_size = lmb_get_free_size(&lmb, load_addr);
        if (!max_size)