]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-4.4/cxgb3-l2t-fix-undefined-behaviour.patch
drop rdma-cma-consider-scope_id-while-binding-to-ipv6-ll-.patch from 4.4, 4.9, and...
[thirdparty/kernel/stable-queue.git] / queue-4.4 / cxgb3-l2t-fix-undefined-behaviour.patch
CommitLineData
1143c684
SL
1From 153b291de4f8fe6edf2d9c4745c2763771fefcb2 Mon Sep 17 00:00:00 2001
2From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
3Date: Fri, 29 Mar 2019 10:27:26 -0500
4Subject: cxgb3/l2t: Fix undefined behaviour
5
6[ Upstream commit 76497732932f15e7323dc805e8ea8dc11bb587cf ]
7
8The use of zero-sized array causes undefined behaviour when it is not
9the last member in a structure. As it happens to be in this case.
10
11Also, the current code makes use of a language extension to the C90
12standard, but the preferred mechanism to declare variable-length
13types such as this one is a flexible array member, introduced in
14C99:
15
16struct foo {
17 int stuff;
18 struct boo array[];
19};
20
21By making use of the mechanism above, we will get a compiler warning
22in case the flexible array does not occur last. Which is beneficial
23to cultivate a high-quality code.
24
25Fixes: e48f129c2f20 ("[SCSI] cxgb3i: convert cdev->l2opt to use rcu to prevent NULL dereference")
26Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
27Signed-off-by: David S. Miller <davem@davemloft.net>
28Signed-off-by: Sasha Levin <sashal@kernel.org>
29---
30 drivers/net/ethernet/chelsio/cxgb3/l2t.h | 2 +-
31 1 file changed, 1 insertion(+), 1 deletion(-)
32
33diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
34index 8cffcdfd56782..38b5858c335a9 100644
35--- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
36+++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
37@@ -75,8 +75,8 @@ struct l2t_data {
38 struct l2t_entry *rover; /* starting point for next allocation */
39 atomic_t nfree; /* number of free entries */
40 rwlock_t lock;
41- struct l2t_entry l2tab[0];
42 struct rcu_head rcu_head; /* to handle rcu cleanup */
43+ struct l2t_entry l2tab[];
44 };
45
46 typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
47--
482.20.1
49