]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
cxgb3/l2t: Fix undefined behaviour
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Fri, 29 Mar 2019 15:27:26 +0000 (10:27 -0500)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commit145a5ff49dfc19b4606de9eee09e119f0f6f10ab
tree1d8ff7e5f0508928d9d16791e88860787e86ca0a
parentf16aa9be1ec8d30f531443f9f3c62c09ba2771e7
cxgb3/l2t: Fix undefined behaviour

BugLink: https://bugs.launchpad.net/bugs/1838700
[ Upstream commit 76497732932f15e7323dc805e8ea8dc11bb587cf ]

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: e48f129c2f20 ("[SCSI] cxgb3i: convert cdev->l2opt to use rcu to prevent NULL dereference")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/net/ethernet/chelsio/cxgb3/l2t.h