Fix memory initialization in ag7240.c
authorTobias Diedrich <ranma+coreboot@tdiedrich.de>
Mon, 19 Oct 2015 17:36:59 +0000 (19:36 +0200)
committerTobias Diedrich <ranma+coreboot@tdiedrich.de>
Mon, 19 Oct 2015 17:36:59 +0000 (19:36 +0200)
Only the first sizeof(ptr) bytes were initialized correctly.
This leads to a crash in ag7250_send() if mac->next_tx is uninitialized
(if the memory returned by malloc() is not nulled).

u-boot/cpu/mips/ar7240/ag7240.c

index 191da09cc7659de18cf92038aab54cb0a1384009..6f5a33e456e62b4ffe6f738fba0276691882780f 100644 (file)
@@ -535,8 +535,8 @@ int ag7240_enet_initialize(bd_t * bis) {
                        return 0;
                }
 
-               memset(ag7240_macs[i], 0, sizeof(ag7240_macs[i]));
-               memset(dev[i], 0, sizeof(dev[i]));
+               memset(ag7240_macs[i], 0, sizeof(*ag7240_macs[i]));
+               memset(dev[i], 0, sizeof(*dev[i]));
 
                sprintf(dev[i]->name, "eth%d", i);
                ag7240_get_ethaddr(dev[i]);