From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Kalle Valo <kvalo@qca.qualcomm.com>,
Erik Stromdahl <erik.stromdahl@gmail.com>,
"ath10k@lists.infradead.org" <ath10k@lists.infradead.org>,
linux-wireless <linux-wireless@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: ath10k: ret used but uninitialized
Date: Fri, 7 Jul 2017 16:15:58 +0200 [thread overview]
Message-ID: <CAMuHMdVDe2XRxnekL=1LuudsLh_p09Ap92LqeouXnC_H5p6DiQ@mail.gmail.com> (raw)
In-Reply-To: <CAK8P3a1CAmHcywnzngo1UOE69ZZZDVbocVEUFt6Uyy05fpaK5w@mail.gmail.com>
Hi Arnd,
On Fri, Jul 7, 2017 at 4:14 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Fri, Jul 7, 2017 at 12:04 PM, Kalle Valo <kvalo@qca.qualcomm.com> wrote:
>> Erik Stromdahl <erik.stromdahl@gmail.com> writes:
>>>> With gcc 4.1.2:
>>>>
>>>> drivers/net/wireless/ath/ath10k/sdio.c: In function
>>>> ‘ath10k_sdio_mbox_rxmsg_pending_handler’:
>>>> drivers/net/wireless/ath/ath10k/sdio.c:676: warning: ‘ret’ may be used
>>>> uninitialized in this function
>>>>
>>>>> +
>>>>> + *done = true;
>>>>> +
>>>>> + /* Copy the lookahead obtained from the HTC register table into our
>>>>> + * temp array as a start value.
>>>>> + */
>>>>> + lookaheads[0] = msg_lookahead;
>>>>> +
>>>>> + timeout = jiffies + SDIO_MBOX_PROCESSING_TIMEOUT_HZ;
>>>>
>>>> Although very unlikely due to the long timeout, if the code is preempted here,
>>>> and the loop below never entered, ret will indeed be uninitialized.
>>>>
>>>> It's unclear to me what the proper initialization would be, though, so
>>>> that's why I didn't send a patch.
>>>>
>>> I think it would be best to use 0 as initial value of ret in this case.
>>> This will make all other interrupts be processed in a normal way.
>>>
>>> Kalle: Should I create a new patch (initializing ret with zero)?
>>
>> Yes, please send a new patch fixing this.
>>
>> But I don't like that much with the style of initialising ret to zero,
>> it tends to hide things. Instead my preference is something like below
>> where the error handling is more explicit and easier to find where it's
>> exactly failing. But that's just an example how I would try to solve it,
>> it still lacks the handling of -ECANCEL etc.
>
> I think I would simply replace the "while() {}" loop with "do{} while()",
> as that would guarantee it to be run at least once in a way that the
> compiler can see.
Right, that's probably the simplest and cleanest solution.
Gr{oetje,eeting}s,
Geert
prev parent reply other threads:[~2017-07-07 14:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-06 8:27 ath10k: ret used but uninitialized (was: Re: ath10k: add initial SDIO support) Geert Uytterhoeven
[not found] ` <CAMuHMdWVYA4TejcTjOQh7CBfFwJ=q59pzvuHrpH91Kx=-BK9fg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-06 20:01 ` Erik Stromdahl
2017-07-07 10:04 ` ath10k: ret used but uninitialized Kalle Valo
2017-07-07 14:14 ` Arnd Bergmann
2017-07-07 14:15 ` Geert Uytterhoeven [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='CAMuHMdVDe2XRxnekL=1LuudsLh_p09Ap92LqeouXnC_H5p6DiQ@mail.gmail.com' \
--to=geert@linux-m68k.org \
--cc=arnd@arndb.de \
--cc=ath10k@lists.infradead.org \
--cc=erik.stromdahl@gmail.com \
--cc=kvalo@qca.qualcomm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).