lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 5 Mar 2018 23:39:34 -0600
From:   "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To:     Santosh Raspatur <santosh@...lsio.com>
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        "Gustavo A. R. Silva" <garsilva@...eddedor.com>
Subject: [PATCH] cxgb3: remove VLA

In preparation to enabling -Wvla, remove VLA and replace it
with dynamic memory allocation.

Signed-off-by: Gustavo A. R. Silva <gustavo@...eddedor.com>
---
 drivers/net/ethernet/chelsio/cxgb3/t3_hw.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
index a89721f..ad6a280 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
@@ -683,20 +683,37 @@ int t3_seeprom_wp(struct adapter *adapter, int enable)
 
 static int vpdstrtouint(char *s, int len, unsigned int base, unsigned int *val)
 {
-	char tok[len + 1];
+	char *tok;
+	int ret;
+
+	tok = kcalloc(len + 1, sizeof(*tok), GFP_KERNEL);
+	if (!tok)
+		return -ENOMEM;
 
 	memcpy(tok, s, len);
 	tok[len] = 0;
-	return kstrtouint(strim(tok), base, val);
+	ret = kstrtouint(strim(tok), base, val);
+
+	kfree(tok);
+	return ret;
 }
 
 static int vpdstrtou16(char *s, int len, unsigned int base, u16 *val)
 {
-	char tok[len + 1];
+	char *tok;
+	int ret;
+
+	tok = kcalloc(len + 1, sizeof(*tok), GFP_KERNEL);
+	if (!tok)
+		return -ENOMEM;
 
 	memcpy(tok, s, len);
 	tok[len] = 0;
-	return kstrtou16(strim(tok), base, val);
+
+	ret = kstrtou16(strim(tok), base, val);
+
+	kfree(tok);
+	return ret;
 }
 
 /**
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ