diff mbox series

net: bmac: Fix read of MAC address from ROM

Message ID 20200519010558.24805-1-jk@ozlabs.org
State Accepted
Delegated to: David Miller
Headers show
Series net: bmac: Fix read of MAC address from ROM | expand

Commit Message

Jeremy Kerr May 19, 2020, 1:05 a.m. UTC
In bmac_get_station_address, We're reading two bytes at a time from ROM,
but we do that six times, resulting in 12 bytes of read & writes. This
means we will write off the end of the six-byte destination buffer.

This change fixes the for-loop to only read/write six bytes.

Based on a proposed fix from Finn Thain <fthain@telegraphics.com.au>.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Reported-by: Stan Johnson <userm57@yahoo.com>
Tested-by: Stan Johnson <userm57@yahoo.com>
Reported-by: Finn Thain <fthain@telegraphics.com.au>
---
 drivers/net/ethernet/apple/bmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Miller May 19, 2020, 7:03 p.m. UTC | #1
From: Jeremy Kerr <jk@ozlabs.org>
Date: Tue, 19 May 2020 09:05:58 +0800

> In bmac_get_station_address, We're reading two bytes at a time from ROM,
> but we do that six times, resulting in 12 bytes of read & writes. This
> means we will write off the end of the six-byte destination buffer.
> 
> This change fixes the for-loop to only read/write six bytes.
> 
> Based on a proposed fix from Finn Thain <fthain@telegraphics.com.au>.
> 
> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
> Reported-by: Stan Johnson <userm57@yahoo.com>
> Tested-by: Stan Johnson <userm57@yahoo.com>
> Reported-by: Finn Thain <fthain@telegraphics.com.au>

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/apple/bmac.c b/drivers/net/ethernet/apple/bmac.c
index a58185b1d8bf..3e3711b60d01 100644
--- a/drivers/net/ethernet/apple/bmac.c
+++ b/drivers/net/ethernet/apple/bmac.c
@@ -1182,7 +1182,7 @@  bmac_get_station_address(struct net_device *dev, unsigned char *ea)
 	int i;
 	unsigned short data;
 
-	for (i = 0; i < 6; i++)
+	for (i = 0; i < 3; i++)
 		{
 			reset_and_select_srom(dev);
 			data = read_srom(dev, i + EnetAddressOffset/2, SROMAddressBits);