Skip to content

Commit

Permalink
cxgb3: remove VLA usage
Browse files Browse the repository at this point in the history
Remove VLA usage and change the 'len' argument to a u8 and use a 256
byte buffer on the stack. Notice that these lengths are limited by the
encoding field in the VPD structure, which is a u8 [1].

[1] https://marc.info/?l=linux-netdev&m=152044354814024&w=2

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Gustavo A. R. Silva authored and David S. Miller committed Mar 7, 2018
1 parent 334e641 commit c33b3b9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,18 +681,18 @@ int t3_seeprom_wp(struct adapter *adapter, int enable)
return t3_seeprom_write(adapter, EEPROM_STAT_ADDR, enable ? 0xc : 0);
}

static int vpdstrtouint(char *s, int len, unsigned int base, unsigned int *val)
static int vpdstrtouint(char *s, u8 len, unsigned int base, unsigned int *val)
{
char tok[len + 1];
char tok[256];

memcpy(tok, s, len);
tok[len] = 0;
return kstrtouint(strim(tok), base, val);
}

static int vpdstrtou16(char *s, int len, unsigned int base, u16 *val)
static int vpdstrtou16(char *s, u8 len, unsigned int base, u16 *val)
{
char tok[len + 1];
char tok[256];

memcpy(tok, s, len);
tok[len] = 0;
Expand Down

0 comments on commit c33b3b9

Please sign in to comment.