[PATCH 2/3] arm: imx6: ocotp: Added write check

Daniel Schultz d.schultz at phytec.de
Wed Nov 30 03:10:44 PST 2016


Since it's forbidden to use a multicast address as ethernet address,
the driver should check the addresses before they got written.

Signed-off-by: Daniel Schultz <d.schultz at phytec.de>
---
 arch/arm/mach-imx/ocotp.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/mach-imx/ocotp.c b/arch/arm/mach-imx/ocotp.c
index 9efa46a..f8978c0 100644
--- a/arch/arm/mach-imx/ocotp.c
+++ b/arch/arm/mach-imx/ocotp.c
@@ -452,6 +452,12 @@ static int imx_ocotp_set_mac(unsigned int mac_no, struct param_d *param,
 	for (i = 0; i < 6; i++)
 		buf[5 - i + offset] = ocotp_priv->ethaddr[mac_no][i];
 
+	if (0x01 & buf[5 + offset]) {
+		dev_err(&ocotp_priv->dev,
+			"this MAC address is a broadcast/multicast\n");
+		return -EINVAL;
+	}
+
 	ret = regmap_bulk_write(ocotp_priv->map,
 				(mac_no == 0) ? MAC0_OFFSET : MAC1_OFFSET, buf,
 				MAC_BYTES);
-- 
1.9.1




More information about the barebox mailing list