From: Jie Zhou <jizh@linux.microsoft.com>
To: dev@dpdk.org
Cc: dmitry.kozliuk@gmail.com, roretzla@microsoft.com,
talshn@nvidia.com, pallavi.kadam@intel.com,
navasile@linux.microsoft.com, dmitrym@microsoft.com,
david.marchand@redhat.com, stable@dpdk.org
Subject: [dpdk-stable] [PATCH v2] eal/windows: enforce alarm APIs parameter check
Date: Wed, 7 Jul 2021 13:25:38 -0700 [thread overview]
Message-ID: <1625689538-6747-1-git-send-email-jizh@linux.microsoft.com> (raw)
In-Reply-To: <1624495001-16613-1-git-send-email-jizh@linux.microsoft.com>
eal/windows alarm APIs rte_eal_alarm_set and rte_eal_alarm_cancel
did not check parameters to fail fast for invalid parameters, which
caught by DPDK UT alarm_autotest.
Enforce eal/windows alarm APIs parameter check to fail fast for
invalid parameters.
Fixes: f4cbdbc7fbd2 ("eal/windows: implement alarm API")
Cc: stable@dpdk.org
Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
---
V2 changes:
- Remove API parameter check on arbitrary 'us' range
- Do explicit NULL cb_fn check
---
lib/eal/windows/eal_alarm.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/lib/eal/windows/eal_alarm.c b/lib/eal/windows/eal_alarm.c
index f5bf88715a..e5dc54efb8 100644
--- a/lib/eal/windows/eal_alarm.c
+++ b/lib/eal/windows/eal_alarm.c
@@ -91,6 +91,12 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)
LARGE_INTEGER deadline;
int ret;
+ if (cb_fn == NULL) {
+ RTE_LOG(ERR, EAL, "NULL callback\n");
+ ret = -EINVAL;
+ goto exit;
+ }
+
/* Calculate deadline ASAP, unit of measure = 100ns. */
GetSystemTimePreciseAsFileTime(&ft);
deadline.LowPart = ft.dwLowDateTime;
@@ -180,6 +186,12 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
bool executing;
removed = 0;
+
+ if (cb_fn == NULL) {
+ RTE_LOG(ERR, EAL, "NULL callback\n");
+ return -EINVAL;
+ }
+
do {
executing = false;
--
2.31.0.vfs.0.1
next parent reply other threads:[~2021-07-07 20:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1624495001-16613-1-git-send-email-jizh@linux.microsoft.com>
2021-07-07 20:25 ` Jie Zhou [this message]
2021-07-21 15:28 ` Dmitry Kozlyuk
2021-07-22 20:06 ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
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=1625689538-6747-1-git-send-email-jizh@linux.microsoft.com \
--to=jizh@linux.microsoft.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=dmitry.kozliuk@gmail.com \
--cc=dmitrym@microsoft.com \
--cc=navasile@linux.microsoft.com \
--cc=pallavi.kadam@intel.com \
--cc=roretzla@microsoft.com \
--cc=stable@dpdk.org \
--cc=talshn@nvidia.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).