From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0E971A0C4B for ; Wed, 7 Jul 2021 22:25:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F423C4156C; Wed, 7 Jul 2021 22:25:47 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 27CE8413B6; Wed, 7 Jul 2021 22:25:45 +0200 (CEST) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 7471F20B7188; Wed, 7 Jul 2021 13:25:44 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7471F20B7188 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1625689544; bh=B4CUSz/UEa0B9VWX+a44CYdIbWNqx+95Y48B3WRmwZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QPewgFPlCvMhbqCA8k/pmizQwp33k5DT5tdcwj5Wg4Gggo6a36qLzjnPrWNcfA2TS UoVeFm+9Cl5RShzwo66E5H4FWD0+n03VLnRupgCkWzczKwgtP76UAHJJkz7KvhvByS C//hVPiYK2aTUj1tbjrHDPPSlznFUdgBG3OO+fPs= From: Jie Zhou 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 Date: Wed, 7 Jul 2021 13:25:38 -0700 Message-Id: <1625689538-6747-1-git-send-email-jizh@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1624495001-16613-1-git-send-email-jizh@linux.microsoft.com> References: <1624495001-16613-1-git-send-email-jizh@linux.microsoft.com> Subject: [dpdk-stable] [PATCH v2] eal/windows: enforce alarm APIs parameter check X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 --- 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