OSDN Git Service

netfilter: nat: Do not use ARRAY_SIZE() on spinlocks to fix zero div
authorGeert Uytterhoeven <geert@linux-m68k.org>
Sun, 10 Sep 2017 11:41:41 +0000 (13:41 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 18 Sep 2017 15:33:23 +0000 (17:33 +0200)
commitb0ade85165b3caeb0cd908cffe5921a39f25c243
treecaf9d5d748d811e56b98d23bcba80b70c89f3176
parent2bd6bf03f4c1c59381d62c61d03f6cc3fe71f66e
netfilter: nat: Do not use ARRAY_SIZE() on spinlocks to fix zero div

If no spinlock debugging options (CONFIG_GENERIC_LOCKBREAK,
CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_LOCK_ALLOC) are enabled on a UP
platform (e.g. m68k defconfig), arch_spinlock_t is an empty struct,
hence using ARRAY_SIZE(nf_nat_locks) causes a division by zero:

    net/netfilter/nf_nat_core.c: In function ‘nf_nat_setup_info’:
    net/netfilter/nf_nat_core.c:432: warning: division by zero
    net/netfilter/nf_nat_core.c: In function ‘__nf_nat_cleanup_conntrack’:
    net/netfilter/nf_nat_core.c:535: warning: division by zero
    net/netfilter/nf_nat_core.c:537: warning: division by zero
    net/netfilter/nf_nat_core.c: In function ‘nf_nat_init’:
    net/netfilter/nf_nat_core.c:810: warning: division by zero
    net/netfilter/nf_nat_core.c:811: warning: division by zero
    net/netfilter/nf_nat_core.c:824: warning: division by zero

Fix this by using the CONNTRACK_LOCKS definition instead.

Suggested-by: Florian Westphal <fw@strlen.de>
Fixes: 8073e960a03bf7b5 ("netfilter: nat: use keyed locks")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_nat_core.c