From: Arend Van Spriel <arend.vanspriel@broadcom.com>
To: Jonas Gorski <jonas.gorski@gmail.com>, Su Hui <suhui@nfschina.com>
Cc: <kvalo@kernel.org>, <johannes.berg@intel.com>, <kees@kernel.org>,
<a@bayrepo.ru>, <quic_alokad@quicinc.com>, <zyytlz.wz@163.com>,
<marcan@marcan.st>, <petr.tesarik.ext@huawei.com>,
<duoming@zju.edu.cn>, <colin.i.king@gmail.com>,
<u.kleine-koenig@pengutronix.de>, <quic_jjohnson@quicinc.com>,
<linville@tuxdriver.com>, <pieterpg@broadcom.com>,
<meuleman@broadcom.com>, <frankyl@broadcom.com>,
<stanley.hsu@cypress.com>, <wright.feng@cypress.com>,
<ian.lin@infineon.com>, <chi-hsien.lin@cypress.com>,
<zajec5@gmail.com>, <antonio@open-mesh.com>,
<franky.lin@broadcom.com>, <linux-wireless@vger.kernel.org>,
<brcm80211@lists.linux.dev>,
<brcm80211-dev-list.pdl@broadcom.com>,
<linux-kernel@vger.kernel.org>, <kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH wireless 0/9] wifi: cfg80211: avoid some garbage values
Date: Tue, 02 Jul 2024 17:01:09 +0200 [thread overview]
Message-ID: <19073f6bf08.279b.9b12b7fc0a3841636cfb5e919b41b954@broadcom.com> (raw)
In-Reply-To: <CAOiHx=n5rfCBkO8wfqpa=UgL==Ty9=s1f=roVHiaFy2acQOHtw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1860 bytes --]
On July 2, 2024 4:02:39 PM Jonas Gorski <jonas.gorski@gmail.com> wrote:
> Hi,
>
> On Tue, 2 Jul 2024 at 14:50, Su Hui <suhui@nfschina.com> wrote:
>>
>> Clang static checker (scan-build) has some warnings as follows.
>>
>> included from drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c:16
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.h:123:2:
>> warning:Assigned value is garbage or undefined [core.uninitialized.Assign]
>> 123 | __le32 data_le = cpu_to_le32(*data);
>> | ^~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c:138:3:warning
>> Value stored to 'err' is never read [deadcode.DeadStores]
>>
>> There are some functions like brcmf_fil_{cmd,iovar,basscfg}_int_get()
>> which read the value of its parameter, but some callers have not
>> initialized these parameters which will be read. And this patchset fixes
>> these problems.
>
> The core issue here seems to be that
> brcmf_fil_{cmd,iovar,basscfg}_int_get() function (needlessly?) read
> from *data.
>
> So instead of forcing all callers of
> brcmf_fil_{cmd,iovar,basscfg}_int_get() to initialize *data first, I
> suggest changing brcmf_fil_{cmd,iovar,basscfg}_int_get() to just not
> read from it.
>
> I see no reason why they should care about what the previous value
> was, since they are supposed to overwrite it anyway.
The issue here is that these are generic functions and there is a reason.
Some firmware API primitives allow/require the caller to pass selection
parameters in *data. We wanted to keep the functions generic and leave out
that knowledge. I suppose we could introduce a separate set of api
functions for that purpose, but it seems like significant overhead to
silence compiler warnings. Guess I underestimate the potential risk of
leaking few bytes of stack data.
Regards,
Arend
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4219 bytes --]
prev parent reply other threads:[~2024-07-02 15:01 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-02 12:24 [PATCH wireless 0/9] wifi: cfg80211: avoid some garbage values Su Hui
2024-07-02 12:24 ` [PATCH wireless 1/9] wifi: cfg80211: avoid garbage value of 'io_type' in brcmf_cfg80211_attach() Su Hui
2024-07-02 13:57 ` Dan Carpenter
2024-07-02 15:07 ` Arend Van Spriel
2024-07-02 15:29 ` Kalle Valo
2024-07-02 15:37 ` Dan Carpenter
2024-07-02 16:26 ` Arend Van Spriel
2024-07-02 16:37 ` Dan Carpenter
2024-07-02 15:39 ` Arend Van Spriel
2024-07-03 1:41 ` Su Hui
2024-07-03 4:42 ` Arend Van Spriel
2024-07-03 7:38 ` Su Hui
2024-07-03 13:23 ` Dan Carpenter
2024-07-02 12:24 ` [PATCH wireless 2/9] wifi: brcmfmac: avoid garbage value of 'status' in brcmf_c_download_blob() Su Hui
2024-07-02 12:24 ` [PATCH wireless 3/9] wifi: cfg80211: avoid garbage value of 'noise' in brcmf_cfg80211_dump_survey() Su Hui
2024-07-02 12:24 ` [PATCH wireless 4/9] wifi: cfg80211: avoid garbage value of 'chanspec' in brcmf_cfg80211_get_channel() Su Hui
2024-07-02 12:24 ` [PATCH wireless 5/9] wifi: cfg80211: avoid garbage value of 'freq' in brcmf_cfg80211_mgmt_tx() Su Hui
2024-07-02 12:24 ` [PATCH wireless 6/9] wifi: cfg80211: avoid garbage value of 'wsec' in brcmf_cfg80211_reconfigure_wep() Su Hui
2024-07-02 12:24 ` [PATCH wireless 7/9] wifi: cfg80211: avoid garbage value of 'wsec' in brcmf_cfg80211_add_key() Su Hui
2024-07-02 12:24 ` [PATCH wireless 8/9] wifi: cfg80211: avoid garbage value of 'val' in brcmf_set_key_mgmt() Su Hui
2024-07-02 12:24 ` [PATCH wireless 9/9] wifi: cfg80211: avoid garbage value of 'wsec' in brcmf_cfg80211_{get,config_default}_key() Su Hui
2024-07-02 12:49 ` [PATCH wireless 0/9] wifi: cfg80211: avoid some garbage values Johannes Berg
2024-07-02 14:41 ` Arend Van Spriel
2024-07-02 14:02 ` Jonas Gorski
2024-07-02 15:01 ` 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=19073f6bf08.279b.9b12b7fc0a3841636cfb5e919b41b954@broadcom.com \
--to=arend.vanspriel@broadcom.com \
--cc=a@bayrepo.ru \
--cc=antonio@open-mesh.com \
--cc=brcm80211-dev-list.pdl@broadcom.com \
--cc=brcm80211@lists.linux.dev \
--cc=chi-hsien.lin@cypress.com \
--cc=colin.i.king@gmail.com \
--cc=duoming@zju.edu.cn \
--cc=franky.lin@broadcom.com \
--cc=frankyl@broadcom.com \
--cc=ian.lin@infineon.com \
--cc=johannes.berg@intel.com \
--cc=jonas.gorski@gmail.com \
--cc=kees@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kvalo@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=marcan@marcan.st \
--cc=meuleman@broadcom.com \
--cc=petr.tesarik.ext@huawei.com \
--cc=pieterpg@broadcom.com \
--cc=quic_alokad@quicinc.com \
--cc=quic_jjohnson@quicinc.com \
--cc=stanley.hsu@cypress.com \
--cc=suhui@nfschina.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=wright.feng@cypress.com \
--cc=zajec5@gmail.com \
--cc=zyytlz.wz@163.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