From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Santosh Raspatur <santosh@chelsio.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <garsilva@embeddedor.com>
Subject: [PATCH] cxgb3: remove VLA
Date: Mon, 5 Mar 2018 23:39:34 -0600 [thread overview]
Message-ID: <20180306053934.GA17162@embeddedgus> (raw)
In preparation to enabling -Wvla, remove VLA and replace it
with dynamic memory allocation.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.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
next reply other threads:[~2018-03-06 5:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-06 5:39 Gustavo A. R. Silva [this message]
2018-03-07 17:25 ` [PATCH] cxgb3: remove VLA David Miller
2018-03-07 17:30 ` Gustavo A. R. Silva
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180306053934.GA17162@embeddedgus \
--to=gustavo@embeddedor.com \
--cc=garsilva@embeddedor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=santosh@chelsio.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).