diff options
Diffstat (limited to 'net/netlabel/netlabel_unlabeled.c')
-rw-r--r-- | net/netlabel/netlabel_unlabeled.c | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c index e8a5c32b0f10..8c0308032178 100644 --- a/net/netlabel/netlabel_unlabeled.c +++ b/net/netlabel/netlabel_unlabeled.c | |||
@@ -562,7 +562,6 @@ static int netlbl_unlhsh_remove_addr4(struct net *net, | |||
562 | const struct in_addr *mask, | 562 | const struct in_addr *mask, |
563 | struct netlbl_audit *audit_info) | 563 | struct netlbl_audit *audit_info) |
564 | { | 564 | { |
565 | int ret_val = 0; | ||
566 | struct netlbl_af4list *list_entry; | 565 | struct netlbl_af4list *list_entry; |
567 | struct netlbl_unlhsh_addr4 *entry; | 566 | struct netlbl_unlhsh_addr4 *entry; |
568 | struct audit_buffer *audit_buf; | 567 | struct audit_buffer *audit_buf; |
@@ -574,9 +573,10 @@ static int netlbl_unlhsh_remove_addr4(struct net *net, | |||
574 | list_entry = netlbl_af4list_remove(addr->s_addr, mask->s_addr, | 573 | list_entry = netlbl_af4list_remove(addr->s_addr, mask->s_addr, |
575 | &iface->addr4_list); | 574 | &iface->addr4_list); |
576 | spin_unlock(&netlbl_unlhsh_lock); | 575 | spin_unlock(&netlbl_unlhsh_lock); |
577 | if (list_entry == NULL) | 576 | if (list_entry != NULL) |
578 | ret_val = -ENOENT; | 577 | entry = netlbl_unlhsh_addr4_entry(list_entry); |
579 | entry = netlbl_unlhsh_addr4_entry(list_entry); | 578 | else |
579 | entry = NULL; | ||
580 | 580 | ||
581 | audit_buf = netlbl_audit_start_common(AUDIT_MAC_UNLBL_STCDEL, | 581 | audit_buf = netlbl_audit_start_common(AUDIT_MAC_UNLBL_STCDEL, |
582 | audit_info); | 582 | audit_info); |
@@ -587,19 +587,21 @@ static int netlbl_unlhsh_remove_addr4(struct net *net, | |||
587 | addr->s_addr, mask->s_addr); | 587 | addr->s_addr, mask->s_addr); |
588 | if (dev != NULL) | 588 | if (dev != NULL) |
589 | dev_put(dev); | 589 | dev_put(dev); |
590 | if (entry && security_secid_to_secctx(entry->secid, | 590 | if (entry != NULL && |
591 | &secctx, | 591 | security_secid_to_secctx(entry->secid, |
592 | &secctx_len) == 0) { | 592 | &secctx, &secctx_len) == 0) { |
593 | audit_log_format(audit_buf, " sec_obj=%s", secctx); | 593 | audit_log_format(audit_buf, " sec_obj=%s", secctx); |
594 | security_release_secctx(secctx, secctx_len); | 594 | security_release_secctx(secctx, secctx_len); |
595 | } | 595 | } |
596 | audit_log_format(audit_buf, " res=%u", ret_val == 0 ? 1 : 0); | 596 | audit_log_format(audit_buf, " res=%u", entry != NULL ? 1 : 0); |
597 | audit_log_end(audit_buf); | 597 | audit_log_end(audit_buf); |
598 | } | 598 | } |
599 | 599 | ||
600 | if (ret_val == 0) | 600 | if (entry == NULL) |
601 | call_rcu(&entry->rcu, netlbl_unlhsh_free_addr4); | 601 | return -ENOENT; |
602 | return ret_val; | 602 | |
603 | call_rcu(&entry->rcu, netlbl_unlhsh_free_addr4); | ||
604 | return 0; | ||
603 | } | 605 | } |
604 | 606 | ||
605 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 607 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
@@ -623,7 +625,6 @@ static int netlbl_unlhsh_remove_addr6(struct net *net, | |||
623 | const struct in6_addr *mask, | 625 | const struct in6_addr *mask, |
624 | struct netlbl_audit *audit_info) | 626 | struct netlbl_audit *audit_info) |
625 | { | 627 | { |
626 | int ret_val = 0; | ||
627 | struct netlbl_af6list *list_entry; | 628 | struct netlbl_af6list *list_entry; |
628 | struct netlbl_unlhsh_addr6 *entry; | 629 | struct netlbl_unlhsh_addr6 *entry; |
629 | struct audit_buffer *audit_buf; | 630 | struct audit_buffer *audit_buf; |
@@ -634,9 +635,10 @@ static int netlbl_unlhsh_remove_addr6(struct net *net, | |||
634 | spin_lock(&netlbl_unlhsh_lock); | 635 | spin_lock(&netlbl_unlhsh_lock); |
635 | list_entry = netlbl_af6list_remove(addr, mask, &iface->addr6_list); | 636 | list_entry = netlbl_af6list_remove(addr, mask, &iface->addr6_list); |
636 | spin_unlock(&netlbl_unlhsh_lock); | 637 | spin_unlock(&netlbl_unlhsh_lock); |
637 | if (list_entry == NULL) | 638 | if (list_entry != NULL) |
638 | ret_val = -ENOENT; | 639 | entry = netlbl_unlhsh_addr6_entry(list_entry); |
639 | entry = netlbl_unlhsh_addr6_entry(list_entry); | 640 | else |
641 | entry = NULL; | ||
640 | 642 | ||
641 | audit_buf = netlbl_audit_start_common(AUDIT_MAC_UNLBL_STCDEL, | 643 | audit_buf = netlbl_audit_start_common(AUDIT_MAC_UNLBL_STCDEL, |
642 | audit_info); | 644 | audit_info); |
@@ -647,19 +649,21 @@ static int netlbl_unlhsh_remove_addr6(struct net *net, | |||
647 | addr, mask); | 649 | addr, mask); |
648 | if (dev != NULL) | 650 | if (dev != NULL) |
649 | dev_put(dev); | 651 | dev_put(dev); |
650 | if (entry && security_secid_to_secctx(entry->secid, | 652 | if (entry != NULL && |
651 | &secctx, | 653 | security_secid_to_secctx(entry->secid, |
652 | &secctx_len) == 0) { | 654 | &secctx, &secctx_len) == 0) { |
653 | audit_log_format(audit_buf, " sec_obj=%s", secctx); | 655 | audit_log_format(audit_buf, " sec_obj=%s", secctx); |
654 | security_release_secctx(secctx, secctx_len); | 656 | security_release_secctx(secctx, secctx_len); |
655 | } | 657 | } |
656 | audit_log_format(audit_buf, " res=%u", ret_val == 0 ? 1 : 0); | 658 | audit_log_format(audit_buf, " res=%u", entry != NULL ? 1 : 0); |
657 | audit_log_end(audit_buf); | 659 | audit_log_end(audit_buf); |
658 | } | 660 | } |
659 | 661 | ||
660 | if (ret_val == 0) | 662 | if (entry == NULL) |
661 | call_rcu(&entry->rcu, netlbl_unlhsh_free_addr6); | 663 | return -ENOENT; |
662 | return ret_val; | 664 | |
665 | call_rcu(&entry->rcu, netlbl_unlhsh_free_addr6); | ||
666 | return 0; | ||
663 | } | 667 | } |
664 | #endif /* IPv6 */ | 668 | #endif /* IPv6 */ |
665 | 669 | ||