usb: eth: fix memalign() parameter order
PATCH 1/1 usb: eth: fix memalign() parameter order
From: Stephen Warren <[email protected]>
The alignment and size were swapped, leading to malloc heap corruption.
On my system, this sometimes caused U-Boot to crash during or after certain USB Ethernet operations.
--- drivers/usb/eth/usb_ether.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/eth/usb_ether.c +1 -1
@@ -73,7 +73,7 @@ int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize) } ueth->rxsize = rxsize; - ueth->rxbuf =memalign (rxsize,ARCH_DMA_MINALIGN ); + ueth->rxbuf =memalign (ARCH_DMA_MINALIGN , rxsize);if (!ueth->rxbuf)return -ENOMEM ;
Signature · 1 line
2.7.0
PATCH 1/1 usb: eth: fix memalign() parameter order
Quoted 9 lines · Stephen Warren
From: Stephen Warren <[email protected]>
The alignment and size were swapped, leading to malloc heap corruption.
On my system, this sometimes caused U-Boot to crash during or after certain USB Ethernet operations.
Fixes c8c2797c3810 ("dm: usb: eth: Support driver model with USB Ethernet")Signed-off-by Stephen Warren <[email protected]>
Oh this is a nice catch!
Quoted 18 lines
--- drivers/usb/eth/usb_ether.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/eth/usb_ether.c +1
-1@@ -73,7 +73,7 @@ int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize) } ueth->rxsize = rxsize; - ueth->rxbuf =memalign (rxsize,ARCH_DMA_MINALIGN ); + ueth->rxbuf =memalign (ARCH_DMA_MINALIGN , rxsize);if (!ueth->rxbuf)return -ENOMEM ;
PATCH 1/1 usb: eth: fix memalign() parameter order
Quoted 26 lines · Marek Vasut
Quoted 9 lines · Stephen Warren
From: Stephen Warren <[email protected]>
The alignment and size were swapped, leading to malloc heap corruption.
On my system, this sometimes caused U-Boot to crash during or after certain USB Ethernet operations.
Fixes c8c2797c3810 ("dm: usb: eth: Support driver model with USB Ethernet")Signed-off-by Stephen Warren <[email protected]>Oh this is a nice catch!
Acked-by Marek Vasut <[email protected]>Quoted 11 lines
--- drivers/usb/eth/usb_ether.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/eth/usb_ether.c +0
-0@@ -73,7 +73,7 @@ int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize) }
Quoted 8 lines
drivers/usb/eth/usb_ether.c int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize) · line 79
Quoted 7 lines
drivers/usb/eth/usb_ether.c +1
-1ueth->rxsize = rxsize; - ueth->rxbuf =memalign (rxsize,ARCH_DMA_MINALIGN ); + ueth->rxbuf =memalign (ARCH_DMA_MINALIGN , rxsize);if (!ueth->rxbuf)return -ENOMEM ;
Oh dear. For some reason I thought that was fixed. But I see from this thread that it did not fix the problem at the time and I didn't send a patch either:
http://lists.denx.de/pipermail/u-boot/2015-August/222440.html
Thanks Stephen for finding this and actually fixing it :-)
- Simon
PATCH 1/1 usb: eth: fix memalign() parameter order
In reply to Stephen WarrenQuoted 9 lines · Stephen Warren
From: Stephen Warren <[email protected]>
The alignment and size were swapped, leading to malloc heap corruption.
On my system, this sometimes caused U-Boot to crash during or after certain USB Ethernet operations.
Fixes c8c2797c3810 ("dm: usb: eth: Support driver model with USB Ethernet")Signed-off-by Stephen Warren <[email protected]>
Yikes.
PATCH 1/1 usb: eth: fix memalign() parameter order
Quoted 8 lines · Joe Hershberger
Quoted 7 lines · Stephen Warren
From: Stephen Warren <[email protected]>
The alignment and size were swapped, leading to malloc heap corruption.
On my system, this sometimes caused U-Boot to crash during or after certain USB Ethernet operations.
Quoted 7 lines
Quoted 2 lines
Fixes c8c2797c3810 ("dm: usb: eth: Support driver model with USB Ethernet")Signed-off-by Stephen Warren <[email protected]>Yikes.
Reviewed-by Joe Hershberger <[email protected]>
Applied to u-boot-usb/master, thanks.
PATCH 1/1 usb: eth: fix memalign() parameter order
Quoted 9 lines · Marek Vasut
Quoted 8 lines · Joe Hershberger
Quoted 7 lines · Stephen Warren
From: Stephen Warren <[email protected]>
The alignment and size were swapped, leading to malloc heap corruption.
On my system, this sometimes caused U-Boot to crash during or after certain USB Ethernet operations.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Fixes c8c2797c3810 ("dm: usb: eth: Support driver model with USB Ethernet")Signed-off-by Stephen Warren <[email protected]>Yikes.
Reviewed-by Joe Hershberger <[email protected]>Applied to u-boot-usb/master, thanks.
Thanks. Any chance of a pull request into mainline? This issue is causing lots of crashing on one of the systems in my test setup, which potentially masks other problems.
PATCH 1/1 usb: eth: fix memalign() parameter order
Quoted 17 lines · Stephen Warren
Quoted 16 lines · Marek Vasut
Quoted 15 lines · Joe Hershberger
Quoted 10 lines · Stephen Warren
From: Stephen Warren <[email protected]>
The alignment and size were swapped, leading to malloc heap corruption.
On my system, this sometimes caused U-Boot to crash during or after certain USB Ethernet operations.
Fixes c8c2797c3810 ("dm: usb: eth: Support driver model with USBEthernet")
Signed-off-by Stephen Warren <[email protected]>Yikes.
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines
Reviewed-by Joe Hershberger <[email protected]>Applied to u-boot-usb/master, thanks.
Thanks. Any chance of a pull request into mainline? This issue is causing lots of crashing on one of the systems in my test setup, which potentially masks other problems.
Done, sorry for the delay.