Skip to content

Commit d25830e

Browse files
pcmooredavem330
authored andcommitted
netlabel: Fix a potential NULL pointer dereference
Fix a potential NULL pointer dereference seen when trying to remove a static label configuration with an invalid address/mask combination. Signed-off-by: Paul Moore <paul.moore@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent efba018 commit d25830e

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎net/netlabel/netlabel_unlabeled.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,10 @@ static int netlbl_unlhsh_remove_addr4(struct net *net,
574574
list_entry = netlbl_af4list_remove(addr->s_addr, mask->s_addr,
575575
&iface->addr4_list);
576576
spin_unlock(&netlbl_unlhsh_lock);
577-
if (list_entry == NULL)
577+
if (list_entry != NULL)
578+
entry = netlbl_unlhsh_addr4_entry(list_entry);
579+
else
578580
ret_val = -ENOENT;
579-
entry = netlbl_unlhsh_addr4_entry(list_entry);
580581

581582
audit_buf = netlbl_audit_start_common(AUDIT_MAC_UNLBL_STCDEL,
582583
audit_info);
@@ -634,9 +635,10 @@ static int netlbl_unlhsh_remove_addr6(struct net *net,
634635
spin_lock(&netlbl_unlhsh_lock);
635636
list_entry = netlbl_af6list_remove(addr, mask, &iface->addr6_list);
636637
spin_unlock(&netlbl_unlhsh_lock);
637-
if (list_entry == NULL)
638+
if (list_entry != NULL)
639+
entry = netlbl_unlhsh_addr6_entry(list_entry);
640+
else
638641
ret_val = -ENOENT;
639-
entry = netlbl_unlhsh_addr6_entry(list_entry);
640642

641643
audit_buf = netlbl_audit_start_common(AUDIT_MAC_UNLBL_STCDEL,
642644
audit_info);

0 commit comments

Comments
 (0)