[NETFILTER]: nf_nat: fix MASQUERADE crash on device down

Check the return value of nfct_nat() in device_cmp(), we might very well
have non NAT conntrack entries as well (Netfilter bugzilla #528).

Signed-off-by: Martin Josefsson <gandalf@wlug.westbo.se>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Martin Josefsson and committed by David S. Miller bbdc176a c9386cfd

+4 -1
+4 -1
net/ipv4/netfilter/ipt_MASQUERADE.c
··· 127 static inline int 128 device_cmp(struct ip_conntrack *i, void *ifindex) 129 { 130 #ifdef CONFIG_NF_NAT_NEEDED 131 struct nf_conn_nat *nat = nfct_nat(i); 132 #endif 133 - int ret; 134 135 read_lock_bh(&masq_lock); 136 #ifdef CONFIG_NF_NAT_NEEDED
··· 127 static inline int 128 device_cmp(struct ip_conntrack *i, void *ifindex) 129 { 130 + int ret; 131 #ifdef CONFIG_NF_NAT_NEEDED 132 struct nf_conn_nat *nat = nfct_nat(i); 133 + 134 + if (!nat) 135 + return 0; 136 #endif 137 138 read_lock_bh(&masq_lock); 139 #ifdef CONFIG_NF_NAT_NEEDED