diff options
author | David S. Miller <davem@davemloft.net> | 2019-04-01 15:01:46 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-04-01 15:01:46 -0700 |
commit | 3370b5883f04ea955dcf4a466f2962ed804ebe5d (patch) | |
tree | d2d5ac1089ee8ebe3d8a46eb1caafe6ce0aea23d | |
parent | a2c7023f7075ca9b80f944d3f20f60e6574538e2 (diff) | |
parent | db4863fdb897f6c55461a0446592c524dae6bfbe (diff) | |
download | linux-3370b5883f04ea955dcf4a466f2962ed804ebe5d.tar.gz linux-3370b5883f04ea955dcf4a466f2962ed804ebe5d.tar.bz2 linux-3370b5883f04ea955dcf4a466f2962ed804ebe5d.zip |
Merge branch 'cxgb3-undefined-behaviour-and-use-struct_size'
Gustavo A. R. Silva says:
====================
cxgb3/l2t: Fix undefined behaviour and use struct_size() helper
This patchset aims to fix an undefined behaviour when using a zero-sized
array and, add the use of the struct_size() helper in kvzalloc().
You might consider the first patch in this series for stable.
More details in the commit logs.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb3/l2t.c | 4 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb3/l2t.h | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.c b/drivers/net/ethernet/chelsio/cxgb3/l2t.c index 0e9182d3f02c..b3e4118a15e7 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.c +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.c @@ -443,9 +443,9 @@ found: struct l2t_data *t3_init_l2t(unsigned int l2t_capacity) { struct l2t_data *d; - int i, size = sizeof(*d) + l2t_capacity * sizeof(struct l2t_entry); + int i; - d = kvzalloc(size, GFP_KERNEL); + d = kvzalloc(struct_size(d, l2tab, l2t_capacity), GFP_KERNEL); if (!d) return NULL; diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h index c2fd323c4078..ea75f275023f 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h @@ -75,8 +75,8 @@ struct l2t_data { struct l2t_entry *rover; /* starting point for next allocation */ atomic_t nfree; /* number of free entries */ rwlock_t lock; - struct l2t_entry l2tab[0]; struct rcu_head rcu_head; /* to handle rcu cleanup */ + struct l2t_entry l2tab[]; }; typedef void (*arp_failure_handler_func)(struct t3cdev * dev, |