Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'l2tp-avoid-multiple-assignment-remove-BUG_ON'

Tom Parkin says:

====================
l2tp: avoid multiple assignment, remove BUG_ON

l2tp hasn't been kept up to date with the static analysis checks offered
by checkpatch.pl.

This patchset builds on the series: "l2tp: cleanup checkpatch.pl
warnings" and "l2tp: further checkpatch.pl cleanups" to resolve some of
the remaining checkpatch warnings in l2tp.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+38 -23
+10 -12
net/l2tp/l2tp_core.c
··· 621 621 int length) 622 622 { 623 623 struct l2tp_tunnel *tunnel = session->tunnel; 624 + u32 ns = 0, nr = 0; 624 625 int offset; 625 - u32 ns, nr; 626 626 627 627 /* Parse and check optional cookie */ 628 628 if (session->peer_cookie_len > 0) { ··· 644 644 * the control of the LNS. If no sequence numbers present but 645 645 * we were expecting them, discard frame. 646 646 */ 647 - ns = nr = 0; 648 647 L2TP_SKB_CB(skb)->has_seq = 0; 649 648 if (tunnel->version == L2TP_HDR_VER_2) { 650 649 if (hdrflags & L2TP_HDRFLAG_S) { ··· 773 774 774 775 /* Drop skbs from the session's reorder_q 775 776 */ 776 - static int l2tp_session_queue_purge(struct l2tp_session *session) 777 + static void l2tp_session_queue_purge(struct l2tp_session *session) 777 778 { 778 779 struct sk_buff *skb = NULL; 779 780 780 - BUG_ON(!session); 781 - BUG_ON(session->magic != L2TP_SESSION_MAGIC); 781 + if (WARN_ON(session->magic != L2TP_SESSION_MAGIC)) 782 + return; 783 + 782 784 while ((skb = skb_dequeue(&session->reorder_q))) { 783 785 atomic_long_inc(&session->stats.rx_errors); 784 786 kfree_skb(skb); 785 787 } 786 - return 0; 787 788 } 788 789 789 790 /* Internal UDP receive frame. Do the real work of receiving an L2TP data frame ··· 825 826 } 826 827 827 828 /* Point to L2TP header */ 828 - optr = ptr = skb->data; 829 + optr = skb->data; 830 + ptr = skb->data; 829 831 830 832 /* Get L2TP header flags */ 831 833 hdrflags = ntohs(*(__be16 *)ptr); ··· 1188 1188 struct hlist_node *walk; 1189 1189 struct hlist_node *tmp; 1190 1190 struct l2tp_session *session; 1191 - 1192 - BUG_ON(!tunnel); 1193 1191 1194 1192 l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: closing all sessions...\n", 1195 1193 tunnel->name); ··· 1563 1565 { 1564 1566 struct l2tp_tunnel *tunnel = session->tunnel; 1565 1567 1566 - BUG_ON(refcount_read(&session->ref_count) != 0); 1567 - 1568 1568 if (tunnel) { 1569 - BUG_ON(tunnel->magic != L2TP_TUNNEL_MAGIC); 1569 + if (WARN_ON(tunnel->magic != L2TP_TUNNEL_MAGIC)) 1570 + goto out; 1570 1571 l2tp_tunnel_dec_refcount(tunnel); 1571 1572 } 1572 1573 1574 + out: 1573 1575 kfree(session); 1574 1576 } 1575 1577 EXPORT_SYMBOL_GPL(l2tp_session_free);
+4 -1
net/l2tp/l2tp_debugfs.c
··· 72 72 if (!pos) 73 73 goto out; 74 74 75 - BUG_ON(!m->private); 75 + if (WARN_ON(!m->private)) { 76 + pd = NULL; 77 + goto out; 78 + } 76 79 pd = m->private; 77 80 78 81 if (!pd->tunnel)
+8 -4
net/l2tp/l2tp_ip.c
··· 124 124 goto discard; 125 125 126 126 /* Point to L2TP header */ 127 - optr = ptr = skb->data; 127 + optr = skb->data; 128 + ptr = skb->data; 128 129 session_id = ntohl(*((__be32 *)ptr)); 129 130 ptr += 4; 130 131 ··· 154 153 goto discard_sess; 155 154 156 155 /* Point to L2TP header */ 157 - optr = ptr = skb->data; 156 + optr = skb->data; 157 + ptr = skb->data; 158 158 ptr += 4; 159 159 pr_debug("%s: ip recv\n", tunnel->name); 160 160 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length); ··· 286 284 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST) 287 285 goto out; 288 286 289 - if (addr->l2tp_addr.s_addr) 290 - inet->inet_rcv_saddr = inet->inet_saddr = addr->l2tp_addr.s_addr; 287 + if (addr->l2tp_addr.s_addr) { 288 + inet->inet_rcv_saddr = addr->l2tp_addr.s_addr; 289 + inet->inet_saddr = addr->l2tp_addr.s_addr; 290 + } 291 291 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST) 292 292 inet->inet_saddr = 0; /* Use device */ 293 293
+4 -2
net/l2tp/l2tp_ip6.c
··· 137 137 goto discard; 138 138 139 139 /* Point to L2TP header */ 140 - optr = ptr = skb->data; 140 + optr = skb->data; 141 + ptr = skb->data; 141 142 session_id = ntohl(*((__be32 *)ptr)); 142 143 ptr += 4; 143 144 ··· 167 166 goto discard_sess; 168 167 169 168 /* Point to L2TP header */ 170 - optr = ptr = skb->data; 169 + optr = skb->data; 170 + ptr = skb->data; 171 171 ptr += 4; 172 172 pr_debug("%s: ip recv\n", tunnel->name); 173 173 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
+12 -4
net/l2tp/l2tp_ppp.c
··· 163 163 sock_put(sk); 164 164 goto out; 165 165 } 166 - 167 - BUG_ON(session->magic != L2TP_SESSION_MAGIC); 166 + if (WARN_ON(session->magic != L2TP_SESSION_MAGIC)) { 167 + session = NULL; 168 + sock_put(sk); 169 + goto out; 170 + } 168 171 169 172 out: 170 173 return session; ··· 422 419 423 420 if (session) { 424 421 sk->sk_user_data = NULL; 425 - BUG_ON(session->magic != L2TP_SESSION_MAGIC); 422 + if (WARN_ON(session->magic != L2TP_SESSION_MAGIC)) 423 + return; 426 424 l2tp_session_dec_refcount(session); 427 425 } 428 426 } ··· 1478 1474 if (!pos) 1479 1475 goto out; 1480 1476 1481 - BUG_ON(!m->private); 1477 + if (WARN_ON(!m->private)) { 1478 + pd = NULL; 1479 + goto out; 1480 + } 1481 + 1482 1482 pd = m->private; 1483 1483 net = seq_file_net(m); 1484 1484