From: Andrzej Hajda <a.hajda@samsung.com>
To: Hariprasad S <hariprasad@chelsio.com>,
netdev@vger.kernel.org (open list:CXGB4 ETHERNET DRIVER (CXGB4))
Cc: Andrzej Hajda <a.hajda@samsung.com>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] cxgb4: fix invalid checks in alloc_uld_rxqs
Date: Tue, 23 Aug 2016 08:16:19 +0200 [thread overview]
Message-ID: <1471932979-17864-1-git-send-email-a.hajda@samsung.com> (raw)
Local variable msi_idx defined as unsigned int is always >= 0, thus both
'if' checks are always true. On the other side presence of USING_MSIX flag
suggests the checks should not be trivially true.
The simplest solution is to replace incorrect checks with direct testing
of adap->flags and remove spare variables.
The problem has been detected using semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
Hi,
I am not familiar with the code, and it is not clear to me, so my solution
can be incorrect, anyway there is an issue here.
Regards
Andrzej
---
drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
index aac6e44..1e0c952 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
@@ -121,20 +121,14 @@ static int alloc_uld_rxqs(struct adapter *adap,
struct sge_uld_rxq_info *rxq_info,
unsigned int nq, unsigned int offset, bool lro)
{
- struct sge *s = &adap->sge;
struct sge_ofld_rxq *q = rxq_info->uldrxq + offset;
unsigned short *ids = rxq_info->rspq_id + offset;
unsigned int per_chan = nq / adap->params.nports;
- unsigned int msi_idx, bmap_idx;
+ unsigned int bmap_idx;
int i, err;
- if (adap->flags & USING_MSIX)
- msi_idx = 1;
- else
- msi_idx = -((int)s->intrq.abs_id + 1);
-
for (i = 0; i < nq; i++, q++) {
- if (msi_idx >= 0) {
+ if (adap->flags & USING_MSIX) {
bmap_idx = get_msix_idx_from_bmap(adap);
adap->msi_idx++;
}
@@ -147,7 +141,7 @@ static int alloc_uld_rxqs(struct adapter *adap,
0);
if (err)
goto freeout;
- if (msi_idx >= 0)
+ if (adap->flags & USING_MSIX)
rxq_info->msix_tbl[i + offset] = bmap_idx;
memset(&q->stats, 0, sizeof(q->stats));
if (ids)
--
1.9.1
next reply other threads:[~2016-08-23 6:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-23 6:16 Andrzej Hajda [this message]
2016-08-23 7:46 ` [PATCH] cxgb4: fix invalid checks in alloc_uld_rxqs Hariprasad Shenai
2016-08-23 8:01 ` Andrzej Hajda
2016-08-23 8:08 ` Hariprasad Shenai
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=1471932979-17864-1-git-send-email-a.hajda@samsung.com \
--to=a.hajda@samsung.com \
--cc=b.zolnierkie@samsung.com \
--cc=hariprasad@chelsio.com \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--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