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

Merge branch 'l2tp-further-checkpatch-pl-cleanups'

Tom Parkin says:

====================
l2tp: further checkpatch.pl cleanups

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". It includes small refactoring changes which improve code
quality and resolve a subset of the checkpatch warnings for the l2tp
codebase.
====================

Reviewed-by: James Chapman <jchapman@katalix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

+169 -150
+15 -15
net/l2tp/l2tp_core.c
··· 412 412 } 413 413 414 414 /* call private receive handler */ 415 - if (session->recv_skb != NULL) 415 + if (session->recv_skb) 416 416 (*session->recv_skb)(session, skb, L2TP_SKB_CB(skb)->length); 417 417 else 418 418 kfree_skb(skb); ··· 683 683 * check if we sre sending sequence numbers and if not, 684 684 * configure it so. 685 685 */ 686 - if ((!session->lns_mode) && (!session->send_seq)) { 686 + if (!session->lns_mode && !session->send_seq) { 687 687 l2tp_info(session, L2TP_MSG_SEQ, 688 688 "%s: requested to enable seq numbers by LNS\n", 689 689 session->name); ··· 707 707 * If we're the LNS and we're sending sequence numbers, the 708 708 * LAC is broken. Discard the frame. 709 709 */ 710 - if ((!session->lns_mode) && (session->send_seq)) { 710 + if (!session->lns_mode && session->send_seq) { 711 711 l2tp_info(session, L2TP_MSG_SEQ, 712 712 "%s: requested to disable seq numbers by LNS\n", 713 713 session->name); ··· 911 911 struct l2tp_tunnel *tunnel; 912 912 913 913 tunnel = rcu_dereference_sk_user_data(sk); 914 - if (tunnel == NULL) 914 + if (!tunnel) 915 915 goto pass_up; 916 916 917 917 l2tp_dbg(tunnel, L2TP_MSG_DATA, "%s: received %d bytes\n", ··· 1150 1150 { 1151 1151 struct l2tp_tunnel *tunnel = l2tp_tunnel(sk); 1152 1152 1153 - if (tunnel == NULL) 1153 + if (!tunnel) 1154 1154 goto end; 1155 1155 1156 1156 l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: closing...\n", tunnel->name); ··· 1189 1189 struct hlist_node *tmp; 1190 1190 struct l2tp_session *session; 1191 1191 1192 - BUG_ON(tunnel == NULL); 1192 + BUG_ON(!tunnel); 1193 1193 1194 1194 l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: closing all sessions...\n", 1195 1195 tunnel->name); ··· 1214 1214 __l2tp_session_unhash(session); 1215 1215 l2tp_session_queue_purge(session); 1216 1216 1217 - if (session->session_close != NULL) 1217 + if (session->session_close) 1218 1218 (*session->session_close)(session); 1219 1219 1220 1220 l2tp_session_dec_refcount(session); ··· 1389 1389 1390 1390 out: 1391 1391 *sockp = sock; 1392 - if ((err < 0) && sock) { 1392 + if (err < 0 && sock) { 1393 1393 kernel_sock_shutdown(sock, SHUT_RDWR); 1394 1394 sock_release(sock); 1395 1395 *sockp = NULL; ··· 1407 1407 int err; 1408 1408 enum l2tp_encap_type encap = L2TP_ENCAPTYPE_UDP; 1409 1409 1410 - if (cfg != NULL) 1410 + if (cfg) 1411 1411 encap = cfg->encap; 1412 1412 1413 - tunnel = kzalloc(sizeof(struct l2tp_tunnel), GFP_KERNEL); 1414 - if (tunnel == NULL) { 1413 + tunnel = kzalloc(sizeof(*tunnel), GFP_KERNEL); 1414 + if (!tunnel) { 1415 1415 err = -ENOMEM; 1416 1416 goto err; 1417 1417 } ··· 1426 1426 rwlock_init(&tunnel->hlist_lock); 1427 1427 tunnel->acpt_newsess = true; 1428 1428 1429 - if (cfg != NULL) 1429 + if (cfg) 1430 1430 tunnel->debug = cfg->debug; 1431 1431 1432 1432 tunnel->encap = encap; ··· 1615 1615 1616 1616 __l2tp_session_unhash(session); 1617 1617 l2tp_session_queue_purge(session); 1618 - if (session->session_close != NULL) 1618 + if (session->session_close) 1619 1619 (*session->session_close)(session); 1620 1620 1621 1621 l2tp_session_dec_refcount(session); ··· 1647 1647 { 1648 1648 struct l2tp_session *session; 1649 1649 1650 - session = kzalloc(sizeof(struct l2tp_session) + priv_size, GFP_KERNEL); 1651 - if (session != NULL) { 1650 + session = kzalloc(sizeof(*session) + priv_size, GFP_KERNEL); 1651 + if (session) { 1652 1652 session->magic = L2TP_SESSION_MAGIC; 1653 1653 session->tunnel = tunnel; 1654 1654
+11 -9
net/l2tp/l2tp_debugfs.c
··· 58 58 pd->session = l2tp_session_get_nth(pd->tunnel, pd->session_idx); 59 59 pd->session_idx++; 60 60 61 - if (pd->session == NULL) { 61 + if (!pd->session) { 62 62 pd->session_idx = 0; 63 63 l2tp_dfs_next_tunnel(pd); 64 64 } ··· 72 72 if (!pos) 73 73 goto out; 74 74 75 - BUG_ON(m->private == NULL); 75 + BUG_ON(!m->private); 76 76 pd = m->private; 77 77 78 - if (pd->tunnel == NULL) 78 + if (!pd->tunnel) 79 79 l2tp_dfs_next_tunnel(pd); 80 80 else 81 81 l2tp_dfs_next_session(pd); 82 82 83 83 /* NULL tunnel and session indicates end of list */ 84 - if ((pd->tunnel == NULL) && (pd->session == NULL)) 84 + if (!pd->tunnel && !pd->session) 85 85 pd = NULL; 86 86 87 87 out: ··· 146 146 147 147 seq_printf(m, " from %pI6c to %pI6c\n", 148 148 &np->saddr, &tunnel->sock->sk_v6_daddr); 149 - } else 149 + } 150 150 #endif 151 - seq_printf(m, " from %pI4 to %pI4\n", 152 - &inet->inet_saddr, &inet->inet_daddr); 151 + if (tunnel->sock->sk_family == AF_INET) 152 + seq_printf(m, " from %pI4 to %pI4\n", 153 + &inet->inet_saddr, &inet->inet_daddr); 154 + 153 155 if (tunnel->encap == L2TP_ENCAPTYPE_UDP) 154 156 seq_printf(m, " source port %hu, dest port %hu\n", 155 157 ntohs(inet->inet_sport), ntohs(inet->inet_dport)); ··· 223 221 atomic_long_read(&session->stats.rx_bytes), 224 222 atomic_long_read(&session->stats.rx_errors)); 225 223 226 - if (session->show != NULL) 224 + if (session->show) 227 225 session->show(m, session); 228 226 } 229 227 ··· 270 268 int rc = -ENOMEM; 271 269 272 270 pd = kzalloc(sizeof(*pd), GFP_KERNEL); 273 - if (pd == NULL) 271 + if (!pd) 274 272 goto out; 275 273 276 274 /* Derive the network namespace from the pid opening the
+1 -1
net/l2tp/l2tp_ip.c
··· 471 471 rt = (struct rtable *)__sk_dst_check(sk, 0); 472 472 473 473 rcu_read_lock(); 474 - if (rt == NULL) { 474 + if (!rt) { 475 475 const struct ip_options_rcu *inet_opt; 476 476 477 477 inet_opt = rcu_dereference(inet->inet_opt);
+1 -1
net/l2tp/l2tp_ip6.c
··· 486 486 int err = 0; 487 487 488 488 skb = skb_peek(&sk->sk_write_queue); 489 - if (skb == NULL) 489 + if (!skb) 490 490 goto out; 491 491 492 492 transhdr = (__be32 *)skb_transport_header(skb);
+114 -92
net/l2tp/l2tp_netlink.c
··· 155 155 return ret; 156 156 } 157 157 158 + static int l2tp_nl_cmd_tunnel_create_get_addr(struct nlattr **attrs, struct l2tp_tunnel_cfg *cfg) 159 + { 160 + if (attrs[L2TP_ATTR_UDP_SPORT]) 161 + cfg->local_udp_port = nla_get_u16(attrs[L2TP_ATTR_UDP_SPORT]); 162 + if (attrs[L2TP_ATTR_UDP_DPORT]) 163 + cfg->peer_udp_port = nla_get_u16(attrs[L2TP_ATTR_UDP_DPORT]); 164 + cfg->use_udp_checksums = nla_get_flag(attrs[L2TP_ATTR_UDP_CSUM]); 165 + 166 + /* Must have either AF_INET or AF_INET6 address for source and destination */ 167 + #if IS_ENABLED(CONFIG_IPV6) 168 + if (attrs[L2TP_ATTR_IP6_SADDR] && attrs[L2TP_ATTR_IP6_DADDR]) { 169 + cfg->local_ip6 = nla_data(attrs[L2TP_ATTR_IP6_SADDR]); 170 + cfg->peer_ip6 = nla_data(attrs[L2TP_ATTR_IP6_DADDR]); 171 + cfg->udp6_zero_tx_checksums = nla_get_flag(attrs[L2TP_ATTR_UDP_ZERO_CSUM6_TX]); 172 + cfg->udp6_zero_rx_checksums = nla_get_flag(attrs[L2TP_ATTR_UDP_ZERO_CSUM6_RX]); 173 + return 0; 174 + } 175 + #endif 176 + if (attrs[L2TP_ATTR_IP_SADDR] && attrs[L2TP_ATTR_IP_DADDR]) { 177 + cfg->local_ip.s_addr = nla_get_in_addr(attrs[L2TP_ATTR_IP_SADDR]); 178 + cfg->peer_ip.s_addr = nla_get_in_addr(attrs[L2TP_ATTR_IP_DADDR]); 179 + return 0; 180 + } 181 + return -EINVAL; 182 + } 183 + 158 184 static int l2tp_nl_cmd_tunnel_create(struct sk_buff *skb, struct genl_info *info) 159 185 { 160 186 u32 tunnel_id; 161 187 u32 peer_tunnel_id; 162 188 int proto_version; 163 - int fd; 189 + int fd = -1; 164 190 int ret = 0; 165 191 struct l2tp_tunnel_cfg cfg = { 0, }; 166 192 struct l2tp_tunnel *tunnel; ··· 217 191 } 218 192 cfg.encap = nla_get_u16(attrs[L2TP_ATTR_ENCAP_TYPE]); 219 193 220 - fd = -1; 194 + /* Managed tunnels take the tunnel socket from userspace. 195 + * Unmanaged tunnels must call out the source and destination addresses 196 + * for the kernel to create the tunnel socket itself. 197 + */ 221 198 if (attrs[L2TP_ATTR_FD]) { 222 199 fd = nla_get_u32(attrs[L2TP_ATTR_FD]); 223 200 } else { 224 - #if IS_ENABLED(CONFIG_IPV6) 225 - if (attrs[L2TP_ATTR_IP6_SADDR] && attrs[L2TP_ATTR_IP6_DADDR]) { 226 - cfg.local_ip6 = nla_data(attrs[L2TP_ATTR_IP6_SADDR]); 227 - cfg.peer_ip6 = nla_data(attrs[L2TP_ATTR_IP6_DADDR]); 228 - } else 229 - #endif 230 - if (attrs[L2TP_ATTR_IP_SADDR] && attrs[L2TP_ATTR_IP_DADDR]) { 231 - cfg.local_ip.s_addr = nla_get_in_addr(attrs[L2TP_ATTR_IP_SADDR]); 232 - cfg.peer_ip.s_addr = nla_get_in_addr(attrs[L2TP_ATTR_IP_DADDR]); 233 - } else { 234 - ret = -EINVAL; 201 + ret = l2tp_nl_cmd_tunnel_create_get_addr(attrs, &cfg); 202 + if (ret < 0) 235 203 goto out; 236 - } 237 - if (attrs[L2TP_ATTR_UDP_SPORT]) 238 - cfg.local_udp_port = nla_get_u16(attrs[L2TP_ATTR_UDP_SPORT]); 239 - if (attrs[L2TP_ATTR_UDP_DPORT]) 240 - cfg.peer_udp_port = nla_get_u16(attrs[L2TP_ATTR_UDP_DPORT]); 241 - cfg.use_udp_checksums = nla_get_flag(attrs[L2TP_ATTR_UDP_CSUM]); 242 - 243 - #if IS_ENABLED(CONFIG_IPV6) 244 - cfg.udp6_zero_tx_checksums = nla_get_flag(attrs[L2TP_ATTR_UDP_ZERO_CSUM6_TX]); 245 - cfg.udp6_zero_rx_checksums = nla_get_flag(attrs[L2TP_ATTR_UDP_ZERO_CSUM6_RX]); 246 - #endif 247 204 } 248 205 249 206 if (attrs[L2TP_ATTR_DEBUG]) ··· 319 310 return ret; 320 311 } 321 312 313 + #if IS_ENABLED(CONFIG_IPV6) 314 + static int l2tp_nl_tunnel_send_addr6(struct sk_buff *skb, struct sock *sk, 315 + enum l2tp_encap_type encap) 316 + { 317 + struct inet_sock *inet = inet_sk(sk); 318 + struct ipv6_pinfo *np = inet6_sk(sk); 319 + 320 + switch (encap) { 321 + case L2TP_ENCAPTYPE_UDP: 322 + if (udp_get_no_check6_tx(sk) && 323 + nla_put_flag(skb, L2TP_ATTR_UDP_ZERO_CSUM6_TX)) 324 + return -1; 325 + if (udp_get_no_check6_rx(sk) && 326 + nla_put_flag(skb, L2TP_ATTR_UDP_ZERO_CSUM6_RX)) 327 + return -1; 328 + if (nla_put_u16(skb, L2TP_ATTR_UDP_SPORT, ntohs(inet->inet_sport)) || 329 + nla_put_u16(skb, L2TP_ATTR_UDP_DPORT, ntohs(inet->inet_dport))) 330 + return -1; 331 + fallthrough; 332 + case L2TP_ENCAPTYPE_IP: 333 + if (nla_put_in6_addr(skb, L2TP_ATTR_IP6_SADDR, &np->saddr) || 334 + nla_put_in6_addr(skb, L2TP_ATTR_IP6_DADDR, &sk->sk_v6_daddr)) 335 + return -1; 336 + break; 337 + } 338 + return 0; 339 + } 340 + #endif 341 + 342 + static int l2tp_nl_tunnel_send_addr4(struct sk_buff *skb, struct sock *sk, 343 + enum l2tp_encap_type encap) 344 + { 345 + struct inet_sock *inet = inet_sk(sk); 346 + 347 + switch (encap) { 348 + case L2TP_ENCAPTYPE_UDP: 349 + if (nla_put_u8(skb, L2TP_ATTR_UDP_CSUM, !sk->sk_no_check_tx) || 350 + nla_put_u16(skb, L2TP_ATTR_UDP_SPORT, ntohs(inet->inet_sport)) || 351 + nla_put_u16(skb, L2TP_ATTR_UDP_DPORT, ntohs(inet->inet_dport))) 352 + return -1; 353 + fallthrough; 354 + case L2TP_ENCAPTYPE_IP: 355 + if (nla_put_in_addr(skb, L2TP_ATTR_IP_SADDR, inet->inet_saddr) || 356 + nla_put_in_addr(skb, L2TP_ATTR_IP_DADDR, inet->inet_daddr)) 357 + return -1; 358 + break; 359 + } 360 + 361 + return 0; 362 + } 363 + 364 + /* Append attributes for the tunnel address, handling the different attribute types 365 + * used for different tunnel encapsulation and AF_INET v.s. AF_INET6. 366 + */ 367 + static int l2tp_nl_tunnel_send_addr(struct sk_buff *skb, struct l2tp_tunnel *tunnel) 368 + { 369 + struct sock *sk = tunnel->sock; 370 + 371 + if (!sk) 372 + return 0; 373 + 374 + #if IS_ENABLED(CONFIG_IPV6) 375 + if (sk->sk_family == AF_INET6) 376 + return l2tp_nl_tunnel_send_addr6(skb, sk, tunnel->encap); 377 + #endif 378 + return l2tp_nl_tunnel_send_addr4(skb, sk, tunnel->encap); 379 + } 380 + 322 381 static int l2tp_nl_tunnel_send(struct sk_buff *skb, u32 portid, u32 seq, int flags, 323 382 struct l2tp_tunnel *tunnel, u8 cmd) 324 383 { 325 384 void *hdr; 326 385 struct nlattr *nest; 327 - struct sock *sk = NULL; 328 - struct inet_sock *inet; 329 - #if IS_ENABLED(CONFIG_IPV6) 330 - struct ipv6_pinfo *np = NULL; 331 - #endif 332 386 333 387 hdr = genlmsg_put(skb, portid, seq, &l2tp_nl_family, flags, cmd); 334 388 if (!hdr) ··· 405 333 goto nla_put_failure; 406 334 407 335 nest = nla_nest_start_noflag(skb, L2TP_ATTR_STATS); 408 - if (nest == NULL) 336 + if (!nest) 409 337 goto nla_put_failure; 410 338 411 339 if (nla_put_u64_64bit(skb, L2TP_ATTR_TX_PACKETS, ··· 435 363 goto nla_put_failure; 436 364 nla_nest_end(skb, nest); 437 365 438 - sk = tunnel->sock; 439 - if (!sk) 440 - goto out; 366 + if (l2tp_nl_tunnel_send_addr(skb, tunnel)) 367 + goto nla_put_failure; 441 368 442 - #if IS_ENABLED(CONFIG_IPV6) 443 - if (sk->sk_family == AF_INET6) 444 - np = inet6_sk(sk); 445 - #endif 446 - 447 - inet = inet_sk(sk); 448 - 449 - switch (tunnel->encap) { 450 - case L2TP_ENCAPTYPE_UDP: 451 - switch (sk->sk_family) { 452 - case AF_INET: 453 - if (nla_put_u8(skb, L2TP_ATTR_UDP_CSUM, !sk->sk_no_check_tx)) 454 - goto nla_put_failure; 455 - break; 456 - #if IS_ENABLED(CONFIG_IPV6) 457 - case AF_INET6: 458 - if (udp_get_no_check6_tx(sk) && 459 - nla_put_flag(skb, L2TP_ATTR_UDP_ZERO_CSUM6_TX)) 460 - goto nla_put_failure; 461 - if (udp_get_no_check6_rx(sk) && 462 - nla_put_flag(skb, L2TP_ATTR_UDP_ZERO_CSUM6_RX)) 463 - goto nla_put_failure; 464 - break; 465 - #endif 466 - } 467 - if (nla_put_u16(skb, L2TP_ATTR_UDP_SPORT, ntohs(inet->inet_sport)) || 468 - nla_put_u16(skb, L2TP_ATTR_UDP_DPORT, ntohs(inet->inet_dport))) 469 - goto nla_put_failure; 470 - /* fall through */ 471 - case L2TP_ENCAPTYPE_IP: 472 - #if IS_ENABLED(CONFIG_IPV6) 473 - if (np) { 474 - if (nla_put_in6_addr(skb, L2TP_ATTR_IP6_SADDR, 475 - &np->saddr) || 476 - nla_put_in6_addr(skb, L2TP_ATTR_IP6_DADDR, 477 - &sk->sk_v6_daddr)) 478 - goto nla_put_failure; 479 - } else 480 - #endif 481 - if (nla_put_in_addr(skb, L2TP_ATTR_IP_SADDR, 482 - inet->inet_saddr) || 483 - nla_put_in_addr(skb, L2TP_ATTR_IP_DADDR, 484 - inet->inet_daddr)) 485 - goto nla_put_failure; 486 - break; 487 - } 488 - 489 - out: 490 369 genlmsg_end(skb, hdr); 491 370 return 0; 492 371 ··· 498 475 499 476 for (;;) { 500 477 tunnel = l2tp_tunnel_get_nth(net, ti); 501 - if (tunnel == NULL) 478 + if (!tunnel) 502 479 goto out; 503 480 504 481 if (l2tp_nl_tunnel_send(skb, NETLINK_CB(cb->skb).portid, ··· 621 598 cfg.reorder_timeout = nla_get_msecs(info->attrs[L2TP_ATTR_RECV_TIMEOUT]); 622 599 623 600 #ifdef CONFIG_MODULES 624 - if (l2tp_nl_cmd_ops[cfg.pw_type] == NULL) { 601 + if (!l2tp_nl_cmd_ops[cfg.pw_type]) { 625 602 genl_unlock(); 626 603 request_module("net-l2tp-type-%u", cfg.pw_type); 627 604 genl_lock(); 628 605 } 629 606 #endif 630 - if ((l2tp_nl_cmd_ops[cfg.pw_type] == NULL) || 631 - (l2tp_nl_cmd_ops[cfg.pw_type]->session_create == NULL)) { 607 + if (!l2tp_nl_cmd_ops[cfg.pw_type] || !l2tp_nl_cmd_ops[cfg.pw_type]->session_create) { 632 608 ret = -EPROTONOSUPPORT; 633 609 goto out_tunnel; 634 610 } ··· 659 637 u16 pw_type; 660 638 661 639 session = l2tp_nl_session_get(info); 662 - if (session == NULL) { 640 + if (!session) { 663 641 ret = -ENODEV; 664 642 goto out; 665 643 } ··· 684 662 struct l2tp_session *session; 685 663 686 664 session = l2tp_nl_session_get(info); 687 - if (session == NULL) { 665 + if (!session) { 688 666 ret = -ENODEV; 689 667 goto out; 690 668 } ··· 751 729 goto nla_put_failure; 752 730 753 731 nest = nla_nest_start_noflag(skb, L2TP_ATTR_STATS); 754 - if (nest == NULL) 732 + if (!nest) 755 733 goto nla_put_failure; 756 734 757 735 if (nla_put_u64_64bit(skb, L2TP_ATTR_TX_PACKETS, ··· 796 774 int ret; 797 775 798 776 session = l2tp_nl_session_get(info); 799 - if (session == NULL) { 777 + if (!session) { 800 778 ret = -ENODEV; 801 779 goto err; 802 780 } ··· 835 813 int si = cb->args[1]; 836 814 837 815 for (;;) { 838 - if (tunnel == NULL) { 816 + if (!tunnel) { 839 817 tunnel = l2tp_tunnel_get_nth(net, ti); 840 - if (tunnel == NULL) 818 + if (!tunnel) 841 819 goto out; 842 820 } 843 821 844 822 session = l2tp_session_get_nth(tunnel, si); 845 - if (session == NULL) { 823 + if (!session) { 846 824 ti++; 847 825 l2tp_tunnel_dec_refcount(tunnel); 848 826 tunnel = NULL;
+27 -32
net/l2tp/l2tp_ppp.c
··· 154 154 { 155 155 struct l2tp_session *session; 156 156 157 - if (sk == NULL) 157 + if (!sk) 158 158 return NULL; 159 159 160 160 sock_hold(sk); 161 161 session = (struct l2tp_session *)(sk->sk_user_data); 162 - if (session == NULL) { 162 + if (!session) { 163 163 sock_put(sk); 164 164 goto out; 165 165 } ··· 217 217 */ 218 218 rcu_read_lock(); 219 219 sk = rcu_dereference(ps->sk); 220 - if (sk == NULL) 220 + if (!sk) 221 221 goto no_sock; 222 222 223 223 /* If the first two bytes are 0xFF03, consider that it is the PPP's ··· 285 285 /* Get session and tunnel contexts */ 286 286 error = -EBADF; 287 287 session = pppol2tp_sock_to_session(sk); 288 - if (session == NULL) 288 + if (!session) 289 289 goto error; 290 290 291 291 tunnel = session->tunnel; ··· 360 360 361 361 /* Get session and tunnel contexts from the socket */ 362 362 session = pppol2tp_sock_to_session(sk); 363 - if (session == NULL) 363 + if (!session) 364 364 goto abort; 365 365 366 366 tunnel = session->tunnel; ··· 703 703 * tunnel id. 704 704 */ 705 705 if (!info.session_id && !info.peer_session_id) { 706 - if (tunnel == NULL) { 706 + if (!tunnel) { 707 707 struct l2tp_tunnel_cfg tcfg = { 708 708 .encap = L2TP_ENCAPTYPE_UDP, 709 709 .debug = 0, ··· 738 738 } else { 739 739 /* Error if we can't find the tunnel */ 740 740 error = -ENOENT; 741 - if (tunnel == NULL) 741 + if (!tunnel) 742 742 goto end; 743 743 744 744 /* Error if socket is not prepped */ 745 - if (tunnel->sock == NULL) 745 + if (!tunnel->sock) 746 746 goto end; 747 747 } 748 748 ··· 802 802 * the internal context for use by ioctl() and sockopt() 803 803 * handlers. 804 804 */ 805 - if ((session->session_id == 0) && 806 - (session->peer_session_id == 0)) { 805 + if (session->session_id == 0 && session->peer_session_id == 0) { 807 806 error = 0; 808 807 goto out_no_ppp; 809 808 } ··· 910 911 struct pppol2tp_session *pls; 911 912 912 913 error = -ENOTCONN; 913 - if (sk == NULL) 914 + if (!sk) 914 915 goto end; 915 916 if (!(sk->sk_state & PPPOX_CONNECTED)) 916 917 goto end; 917 918 918 919 error = -EBADF; 919 920 session = pppol2tp_sock_to_session(sk); 920 - if (session == NULL) 921 + if (!session) 921 922 goto end; 922 923 923 924 pls = l2tp_session_priv(session); 924 925 tunnel = session->tunnel; 925 926 926 927 inet = inet_sk(tunnel->sock); 927 - if ((tunnel->version == 2) && (tunnel->sock->sk_family == AF_INET)) { 928 + if (tunnel->version == 2 && tunnel->sock->sk_family == AF_INET) { 928 929 struct sockaddr_pppol2tp sp; 929 930 930 931 len = sizeof(sp); ··· 942 943 sp.pppol2tp.addr.sin_addr.s_addr = inet->inet_daddr; 943 944 memcpy(uaddr, &sp, len); 944 945 #if IS_ENABLED(CONFIG_IPV6) 945 - } else if ((tunnel->version == 2) && 946 - (tunnel->sock->sk_family == AF_INET6)) { 946 + } else if (tunnel->version == 2 && tunnel->sock->sk_family == AF_INET6) { 947 947 struct sockaddr_pppol2tpin6 sp; 948 948 949 949 len = sizeof(sp); ··· 960 962 memcpy(&sp.pppol2tp.addr.sin6_addr, &tunnel->sock->sk_v6_daddr, 961 963 sizeof(tunnel->sock->sk_v6_daddr)); 962 964 memcpy(uaddr, &sp, len); 963 - } else if ((tunnel->version == 3) && 964 - (tunnel->sock->sk_family == AF_INET6)) { 965 + } else if (tunnel->version == 3 && tunnel->sock->sk_family == AF_INET6) { 965 966 struct sockaddr_pppol2tpv3in6 sp; 966 967 967 968 len = sizeof(sp); ··· 1176 1179 1177 1180 switch (optname) { 1178 1181 case PPPOL2TP_SO_RECVSEQ: 1179 - if ((val != 0) && (val != 1)) { 1182 + if (val != 0 && val != 1) { 1180 1183 err = -EINVAL; 1181 1184 break; 1182 1185 } ··· 1187 1190 break; 1188 1191 1189 1192 case PPPOL2TP_SO_SENDSEQ: 1190 - if ((val != 0) && (val != 1)) { 1193 + if (val != 0 && val != 1) { 1191 1194 err = -EINVAL; 1192 1195 break; 1193 1196 } ··· 1205 1208 break; 1206 1209 1207 1210 case PPPOL2TP_SO_LNSMODE: 1208 - if ((val != 0) && (val != 1)) { 1211 + if (val != 0 && val != 1) { 1209 1212 err = -EINVAL; 1210 1213 break; 1211 1214 } ··· 1260 1263 return -EFAULT; 1261 1264 1262 1265 err = -ENOTCONN; 1263 - if (sk->sk_user_data == NULL) 1266 + if (!sk->sk_user_data) 1264 1267 goto end; 1265 1268 1266 1269 /* Get session context from the socket */ 1267 1270 err = -EBADF; 1268 1271 session = pppol2tp_sock_to_session(sk); 1269 - if (session == NULL) 1272 + if (!session) 1270 1273 goto end; 1271 1274 1272 1275 /* Special case: if session_id == 0x0000, treat as operation on tunnel 1273 1276 */ 1274 - if ((session->session_id == 0) && 1275 - (session->peer_session_id == 0)) { 1277 + if (session->session_id == 0 && session->peer_session_id == 0) { 1276 1278 tunnel = session->tunnel; 1277 1279 err = pppol2tp_tunnel_setsockopt(sk, tunnel, optname, val); 1278 1280 } else { ··· 1378 1382 return -EINVAL; 1379 1383 1380 1384 err = -ENOTCONN; 1381 - if (sk->sk_user_data == NULL) 1385 + if (!sk->sk_user_data) 1382 1386 goto end; 1383 1387 1384 1388 /* Get the session context */ 1385 1389 err = -EBADF; 1386 1390 session = pppol2tp_sock_to_session(sk); 1387 - if (session == NULL) 1391 + if (!session) 1388 1392 goto end; 1389 1393 1390 1394 /* Special case: if session_id == 0x0000, treat as operation on tunnel */ 1391 - if ((session->session_id == 0) && 1392 - (session->peer_session_id == 0)) { 1395 + if (session->session_id == 0 && session->peer_session_id == 0) { 1393 1396 tunnel = session->tunnel; 1394 1397 err = pppol2tp_tunnel_getsockopt(sk, tunnel, optname, &val); 1395 1398 if (err) ··· 1459 1464 pd->session = l2tp_session_get_nth(pd->tunnel, pd->session_idx); 1460 1465 pd->session_idx++; 1461 1466 1462 - if (pd->session == NULL) { 1467 + if (!pd->session) { 1463 1468 pd->session_idx = 0; 1464 1469 pppol2tp_next_tunnel(net, pd); 1465 1470 } ··· 1474 1479 if (!pos) 1475 1480 goto out; 1476 1481 1477 - BUG_ON(m->private == NULL); 1482 + BUG_ON(!m->private); 1478 1483 pd = m->private; 1479 1484 net = seq_file_net(m); 1480 1485 1481 - if (pd->tunnel == NULL) 1486 + if (!pd->tunnel) 1482 1487 pppol2tp_next_tunnel(net, pd); 1483 1488 else 1484 1489 pppol2tp_next_session(net, pd); 1485 1490 1486 1491 /* NULL tunnel and session indicates end of list */ 1487 - if ((pd->tunnel == NULL) && (pd->session == NULL)) 1492 + if (!pd->tunnel && !pd->session) 1488 1493 pd = NULL; 1489 1494 1490 1495 out: