@@ -85,6 +85,7 @@ static void netlbl_domhsh_free_entry(struct rcu_head *entry)
8585 kfree (netlbl_domhsh_addr6_entry (iter6 ));
8686 }
8787#endif /* IPv6 */
88+ kfree (ptr -> def .addrsel );
8889 }
8990 kfree (ptr -> domain );
9091 kfree (ptr );
@@ -536,6 +537,8 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
536537 goto add_return ;
537538 }
538539#endif /* IPv6 */
540+ /* cleanup the new entry since we've moved everything over */
541+ netlbl_domhsh_free_entry (& entry -> rcu );
539542 } else
540543 ret_val = - EINVAL ;
541544
@@ -579,6 +582,12 @@ int netlbl_domhsh_remove_entry(struct netlbl_dom_map *entry,
579582{
580583 int ret_val = 0 ;
581584 struct audit_buffer * audit_buf ;
585+ struct netlbl_af4list * iter4 ;
586+ struct netlbl_domaddr4_map * map4 ;
587+ #if IS_ENABLED (CONFIG_IPV6 )
588+ struct netlbl_af6list * iter6 ;
589+ struct netlbl_domaddr6_map * map6 ;
590+ #endif /* IPv6 */
582591
583592 if (entry == NULL )
584593 return - ENOENT ;
@@ -596,6 +605,9 @@ int netlbl_domhsh_remove_entry(struct netlbl_dom_map *entry,
596605 ret_val = - ENOENT ;
597606 spin_unlock (& netlbl_domhsh_lock );
598607
608+ if (ret_val )
609+ return ret_val ;
610+
599611 audit_buf = netlbl_audit_start_common (AUDIT_MAC_MAP_DEL , audit_info );
600612 if (audit_buf != NULL ) {
601613 audit_log_format (audit_buf ,
@@ -605,40 +617,29 @@ int netlbl_domhsh_remove_entry(struct netlbl_dom_map *entry,
605617 audit_log_end (audit_buf );
606618 }
607619
608- if (ret_val == 0 ) {
609- struct netlbl_af4list * iter4 ;
610- struct netlbl_domaddr4_map * map4 ;
611- #if IS_ENABLED (CONFIG_IPV6 )
612- struct netlbl_af6list * iter6 ;
613- struct netlbl_domaddr6_map * map6 ;
614- #endif /* IPv6 */
615-
616- switch (entry -> def .type ) {
617- case NETLBL_NLTYPE_ADDRSELECT :
618- netlbl_af4list_foreach_rcu (iter4 ,
619- & entry -> def .addrsel -> list4 ) {
620- map4 = netlbl_domhsh_addr4_entry (iter4 );
621- cipso_v4_doi_putdef (map4 -> def .cipso );
622- }
620+ switch (entry -> def .type ) {
621+ case NETLBL_NLTYPE_ADDRSELECT :
622+ netlbl_af4list_foreach_rcu (iter4 , & entry -> def .addrsel -> list4 ) {
623+ map4 = netlbl_domhsh_addr4_entry (iter4 );
624+ cipso_v4_doi_putdef (map4 -> def .cipso );
625+ }
623626#if IS_ENABLED (CONFIG_IPV6 )
624- netlbl_af6list_foreach_rcu (iter6 ,
625- & entry -> def .addrsel -> list6 ) {
626- map6 = netlbl_domhsh_addr6_entry (iter6 );
627- calipso_doi_putdef (map6 -> def .calipso );
628- }
627+ netlbl_af6list_foreach_rcu (iter6 , & entry -> def .addrsel -> list6 ) {
628+ map6 = netlbl_domhsh_addr6_entry (iter6 );
629+ calipso_doi_putdef (map6 -> def .calipso );
630+ }
629631#endif /* IPv6 */
630- break ;
631- case NETLBL_NLTYPE_CIPSOV4 :
632- cipso_v4_doi_putdef (entry -> def .cipso );
633- break ;
632+ break ;
633+ case NETLBL_NLTYPE_CIPSOV4 :
634+ cipso_v4_doi_putdef (entry -> def .cipso );
635+ break ;
634636#if IS_ENABLED (CONFIG_IPV6 )
635- case NETLBL_NLTYPE_CALIPSO :
636- calipso_doi_putdef (entry -> def .calipso );
637- break ;
637+ case NETLBL_NLTYPE_CALIPSO :
638+ calipso_doi_putdef (entry -> def .calipso );
639+ break ;
638640#endif /* IPv6 */
639- }
640- call_rcu (& entry -> rcu , netlbl_domhsh_free_entry );
641641 }
642+ call_rcu (& entry -> rcu , netlbl_domhsh_free_entry );
642643
643644 return ret_val ;
644645}
0 commit comments