starfire: set_vlan_mode contains dead code in a while loop

From: Colin King (gmail)

Date: Tue Mar 10 2026 - 12:16:40 EST


Hi,

There is an issue in function set_vlan_mode with code that is never executed in the following commit:

commit 5da96be53a16a62488316810d0c7c5d58ce3ee4f
Author: Jiri Pirko <jiri@xxxxxxxxxxx>
Date: Wed Jul 20 04:54:31 2011 +0000

starfire: do vlan cleanup


The issue is as follows:

static u32 set_vlan_mode(struct netdev_private *np)
{
u32 ret = VlanMode;
u16 vid;
void __iomem *filter_addr = np->base + HashTable + 8;
int vlan_count = 0;

for_each_set_bit(vid, np->active_vlans, VLAN_N_VID) {
if (vlan_count == 32)
break;
writew(vid, filter_addr);
filter_addr += 16;
vlan_count++;
}
if (vlan_count == 32) {
ret |= PerfectFilterVlan;
while (vlan_count < 32) {
writew(0, filter_addr);
filter_addr += 16;
vlan_count++;
}
}
return ret;
}

If vlan_count is 32 then the while loop is currently dead code since vlan_count cannot be less than 32 (so the loop is never executed).

This logic seems broken.

Colin

Attachment: OpenPGP_0x68C287DFC6A80226.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature