Skip to content

Commit 7649773

Browse files
GustavoARSilvadavem330
authored andcommitted
cxgb3/l2t: Fix undefined behaviour
The use of zero-sized array causes undefined behaviour when it is not the last member in a structure. As it happens to be in this case. Also, the current code makes use of a language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as this one is a flexible array member, introduced in C99: struct foo { int stuff; struct boo array[]; }; By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last. Which is beneficial to cultivate a high-quality code. Fixes: e48f129 ("[SCSI] cxgb3i: convert cdev->l2opt to use rcu to prevent NULL dereference") Signed-off-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a2c7023 commit 7649773

File tree

1 file changed

+1
-1
lines changed
  • drivers/net/ethernet/chelsio/cxgb3

1 file changed

+1
-1
lines changed

drivers/net/ethernet/chelsio/cxgb3/l2t.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ struct l2t_data {
7575
struct l2t_entry *rover; /* starting point for next allocation */
7676
atomic_t nfree; /* number of free entries */
7777
rwlock_t lock;
78-
struct l2t_entry l2tab[0];
7978
struct rcu_head rcu_head; /* to handle rcu cleanup */
79+
struct l2t_entry l2tab[];
8080
};
8181

8282
typedef void (*arp_failure_handler_func)(struct t3cdev * dev,

0 commit comments

Comments
 (0)