From: Kalle Valo <kvalo@codeaurora.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Karthikeyan Periyasamy <periyasa@codeaurora.org>,
Jakub Kicinski <kuba@kernel.org>,
kernel-janitors@vger.kernel.org, linux-wireless@vger.kernel.org,
ath11k@lists.infradead.org
Subject: Re: [PATCH net-next] ath11k: fix uninitialized return in ath11k_spectral_process_data()
Date: Mon, 07 Sep 2020 16:56:11 +0000 [thread overview]
Message-ID: <01010174697f1805-c885f217-9729-4089-91bd-4bd79645fec0-000000@us-west-2.amazonses.com> (raw)
In-Reply-To: <20200622171846.GE4151@kadam> (Dan Carpenter's message of "Mon, 22 Jun 2020 20:18:47 +0300")
Dan Carpenter <dan.carpenter@oracle.com> writes:
> On Mon, Jun 22, 2020 at 05:51:16PM +0300, Kalle Valo wrote:
>> Dan Carpenter <dan.carpenter@oracle.com> writes:
>>
>> > There is a success path where "ret" isn't initialized where we never
>> > have a ATH11K_SPECTRAL_TAG_SCAN_SEARCH and then ret isn't initialized.
>> >
>> > Fixes: 9d11b7bff950 ("ath11k: add support for spectral scan")
>> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>> > ---
>> > drivers/net/wireless/ath/ath11k/spectral.c | 2 +-
>> > 1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/net/wireless/ath/ath11k/spectral.c b/drivers/net/wireless/ath/ath11k/spectral.c
>> > index 1c5d65bb411f..bfbf905f7507 100644
>> > --- a/drivers/net/wireless/ath/ath11k/spectral.c
>> > +++ b/drivers/net/wireless/ath/ath11k/spectral.c
>> > @@ -677,7 +677,7 @@ static int ath11k_spectral_process_data(struct ath11k *ar,
>> > u32 data_len, i;
>> > u8 sign, tag;
>> > int tlv_len, sample_sz;
>> > - int ret;
>> > + int ret = 0;
>> > bool quit = false;
>>
>> I try to avoid initialising ret variables so I would like find another
>> way. What about doing this (completely untested!) in the end of the
>> function:
>>
>> return 0;
>>
>> err:
>> kfree(fft_sample);
>> unlock:
>> spin_unlock_bh(&ar->spectral.lock);
>> return ret;
>
> I normally avoid it as well... If I were to redo this patch, I would
> probably do:
>
> ret = 0;
> err:
> kfree(fft_sample);
> unlock:
> spin_unlock_bh(&ar->spectral.lock);
> return ret;
>
> Would that be better?
Ah, my proposal was buggy. So yes, this is definitely better :) I
changed now the patch in the pending branch, please check:
https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&idX6f8e6779fa75ade112cb48606794e034e0ff1d
--
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
next prev parent reply other threads:[~2020-09-07 16:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-19 14:29 [PATCH net-next] ath11k: fix uninitialized return in ath11k_spectral_process_data() Dan Carpenter
2020-06-22 14:51 ` Kalle Valo
2020-06-22 17:18 ` Dan Carpenter
2020-09-07 16:56 ` Kalle Valo [this message]
2020-09-09 6:49 ` Kalle Valo
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=01010174697f1805-c885f217-9729-4089-91bd-4bd79645fec0-000000@us-west-2.amazonses.com \
--to=kvalo@codeaurora.org \
--cc=ath11k@lists.infradead.org \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=periyasa@codeaurora.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).