• Gustavo A. R. Silva's avatar
    cxgb3/l2t: Fix undefined behaviour · c6d2eb5e
    Gustavo A. R. Silva authored
    [ Upstream commit 76497732 ]
    
    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: e48f129c ("[SCSI] cxgb3i: convert cdev->l2opt to use rcu to prevent NULL dereference")
    Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
    c6d2eb5e
l2t.h 4.88 KB