From: Dan Carpenter <dan.carpenter@oracle.com>
To: Kalle Valo <kvalo@codeaurora.org>
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, 22 Jun 2020 17:18:47 +0000 [thread overview]
Message-ID: <20200622171846.GE4151@kadam> (raw)
In-Reply-To: <87a70vf923.fsf@codeaurora.org>
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?
regards,
dan carpenter
next prev parent reply other threads:[~2020-06-22 17:18 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 [this message]
2020-09-07 16:56 ` Kalle Valo
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=20200622171846.GE4151@kadam \
--to=dan.carpenter@oracle.com \
--cc=ath11k@lists.infradead.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=kvalo@codeaurora.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).