public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: "Colin King (gmail)" <colin.i.king@gmail.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Jiri Pirko <jpirko@redhat.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: starfire: set_vlan_mode contains dead code in a while loop
Date: Tue, 10 Mar 2026 15:04:26 +0000	[thread overview]
Message-ID: <299e76bf-6e7e-4332-a4e2-61698cf95c9a@gmail.com> (raw)


[-- Attachment #1.1.1: Type: text/plain, Size: 1263 bytes --]

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@resnulli.us>
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 #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 4901 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

                 reply	other threads:[~2026-03-10 15:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=299e76bf-6e7e-4332-a4e2-61698cf95c9a@gmail.com \
    --to=colin.i.king@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jpirko@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox