Skip to contentSkip to conversation

bgmac: allow bigger et_swtype nvram variable

PATCH Superseded Rafał Miłecki 2 participants 3 messages Sep 15, 2013 – Sep 17, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bgmac: allow bigger et_swtype nvram variable

Without this patch it is impossible to read et_swtype, because the 1 byte space is needed for the terminating null byte. The max expected value is 0xF, so now it should be possible to read decimal form ("15") and hex form ("0xF").

---
 drivers/net/ethernet/broadcom/bgmac.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bgmac.c +2 -2
index 1c6bc96..59f3e0c 100644
@@ -909,9 +909,9 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
 		u8 et_swtype = 0;
 		u8 sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHY |
 			     BGMAC_CHIPCTL_1_IF_TYPE_MII;
-		char buf[2];
+		char buf[4];
 
-		if (bcm47xx_nvram_getenv("et_swtype", buf, 1) > 0) {
+		if (bcm47xx_nvram_getenv("et_swtype", buf, sizeof(buf)) > 0) {
 			if (kstrtou8(buf, 0, &et_swtype))
 				bgmac_err(bgmac, "Failed to parse et_swtype (%s)\n",
 					  buf);
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v2 1/1 bgmac: allow bigger et_swtype nvram variable

From: Hauke Mehrtens <[email protected]>

Without this patch it is impossible to read et_swtype, because the 1 byte space is needed for the terminating null byte. The max expected value is 0xF, so now it should be possible to read decimal form ("15") and hex form ("0xF").

---
V2: Add "From: " - sorry Hauke for the earlier mistake

---
 drivers/net/ethernet/broadcom/bgmac.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bgmac.c +2 -2
index 1c6bc96..59f3e0c 100644
@@ -909,9 +909,9 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
 		u8 et_swtype = 0;
 		u8 sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHY |
 			     BGMAC_CHIPCTL_1_IF_TYPE_MII;
-		char buf[2];
+		char buf[4];
 
-		if (bcm47xx_nvram_getenv("et_swtype", buf, 1) > 0) {
+		if (bcm47xx_nvram_getenv("et_swtype", buf, sizeof(buf)) > 0) {
 			if (kstrtou8(buf, 0, &et_swtype))
 				bgmac_err(bgmac, "Failed to parse et_swtype (%s)\n",
 					  buf);
Signature · 1 line
1.7.10.4
maintainer Applied
#2 lore raw

From: Rafał Miłecki <[email protected]>
Date: Sun, 15 Sep 2013 22:49:08 +0200

Quoted 9 lines

From: Hauke Mehrtens <[email protected]>

Without this patch it is impossible to read et_swtype, because the 1 byte space is needed for the terminating null byte. The max expected value is 0xF, so now it should be possible to read decimal form ("15") and hex form ("0xF").

Applied.