mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arend van Spriel <arend.vanspriel@broadcom.com>
To: "Colin King (gmail)" <colin.i.king@gmail.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	brcm80211@lists.linux.dev, brcm80211-dev-list.pdl@broadcom.com
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Dmitry Antipov <dmantipov@yandex.ru>
Subject: Re: incorrect shift and mask operation in drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
Date: Wed, 30 Oct 2024 12:08:07 +0100	[thread overview]
Message-ID: <467fd994-01f0-4057-964c-4184a23e59c4@broadcom.com> (raw)
In-Reply-To: <9c02683d-c688-4e39-913e-6b20b3bd76a0@gmail.com>

On 10/15/2024 1:02 AM, Colin King (gmail) wrote:
> Hi,
> 
> Static analysis on drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/ 
> phy_n.c has found an issue with a mask and shift operation in function 
> wlc_phy_rxcal_radio_setup_nphy() as follows:
> 
> lines 26326-26330:
> 
>          offtune_val =
>                  (pi->tx_rx_cal_radio_saveregs
>                   [2] & 0xF0) >> 8;
>          offtune_val =
>                  (offtune_val <= 0x7) ? 0xF : 0;
> 
> and similar in lines 26376-26381 too.
> 
> The issue is that the expression pi->tx_rx_cal_radio_saveregs[2] & 0xF0
> when shifted 8 places right is always zero, so this looks like a mistake 
> since some value value between 0..0xf is expected in the second statement.
> 
> Since pi->tx_rx_cal_radio_saveregs[2] is a u16 value the expression 
> could plausible be:
> 
>      (pi->tx_rx_cal_radio_saveregs[2] & 0xf0) >> 4
> or
>      (pi->tx_rx_cal_radio_saveregs[2] & 0xf00) >> 8
> 
> I don't have knowledge of the hardware so I'm not sure what a suitable 
> fix is.

Thanks, Colin

That looks pretty redundant indeed. I look into the history of it, but 
ended up in an old end-of-life development tree and the code was pretty 
much the same. It is one of the finer dark arts of our phy/radio 
development team I guess ;-)

I see that Dmitry Antipov submitted a patch to address this. Again 
thanks for reporting.

Regards,
Arend

      reply	other threads:[~2024-10-30 11:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14 23:02 Colin King (gmail)
2024-10-30 11:08 ` Arend van Spriel [this message]

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=467fd994-01f0-4057-964c-4184a23e59c4@broadcom.com \
    --to=arend.vanspriel@broadcom.com \
    --cc=brcm80211-dev-list.pdl@broadcom.com \
    --cc=brcm80211@lists.linux.dev \
    --cc=colin.i.king@gmail.com \
    --cc=dmantipov@yandex.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®