From: Timothy McDaniel <timothy.mcdaniel@intel.com>
To: jerinj@marvell.com
Cc: john.mcnamara@intel.com, dev@dpdk.org
Subject: [PATCH] event/dlb2: fix invalid shift value
Date: Wed, 2 Mar 2022 09:12:08 -0600 [thread overview]
Message-ID: <1646233928-4124603-1-git-send-email-timothy.mcdaniel@intel.com> (raw)
Add a check to ensure that all shift counts are valid.
Shifting by more than 63 bits may result in undefined behavior, as
noted during coverity scan.
Fixes: e697f35dbdd1 ("event/dlb2: update rolling mask used for dequeue")
Coverity issue: 376527
Signed-off-by: Timothy McDaniel <timothy.mcdaniel@intel.com>
---
drivers/event/dlb2/dlb2.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c
index 09abdd1660..7789dd74e0 100644
--- a/drivers/event/dlb2/dlb2.c
+++ b/drivers/event/dlb2/dlb2.c
@@ -3916,15 +3916,17 @@ dlb2_hw_dequeue_sparse(struct dlb2_eventdev *dlb2,
&events[num],
&qes[0],
num_avail);
- num += n_iter;
- /* update rolling_mask for vector code support */
- m_rshift = qm_port->cq_rolling_mask >> n_iter;
- m_lshift = qm_port->cq_rolling_mask << (64 - n_iter);
- m2_rshift = qm_port->cq_rolling_mask_2 >> n_iter;
- m2_lshift = qm_port->cq_rolling_mask_2 <<
+ if (n_iter != 0) {
+ num += n_iter;
+ /* update rolling_mask for vector code support */
+ m_rshift = qm_port->cq_rolling_mask >> n_iter;
+ m_lshift = qm_port->cq_rolling_mask << (64 - n_iter);
+ m2_rshift = qm_port->cq_rolling_mask_2 >> n_iter;
+ m2_lshift = qm_port->cq_rolling_mask_2 <<
(64 - n_iter);
- qm_port->cq_rolling_mask = (m_rshift | m2_lshift);
- qm_port->cq_rolling_mask_2 = (m2_rshift | m_lshift);
+ qm_port->cq_rolling_mask = (m_rshift | m2_lshift);
+ qm_port->cq_rolling_mask_2 = (m2_rshift | m_lshift);
+ }
} else { /* !use_scalar */
num_avail = dlb2_recv_qe_sparse_vec(qm_port,
&events[num],
--
2.25.1
next reply other threads:[~2022-03-02 15:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-02 15:12 Timothy McDaniel [this message]
2022-03-03 9:25 ` Jerin Jacob
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=1646233928-4124603-1-git-send-email-timothy.mcdaniel@intel.com \
--to=timothy.mcdaniel@intel.com \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.com \
--cc=john.mcnamara@intel.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;
as well as URLs for NNTP newsgroup(s).