From: Harman Kalra <hkalra@marvell.com>
To: <dev@dpdk.org>, Harman Kalra <hkalra@marvell.com>
Cc: <david.marchand@redhat.com>, <john.mcnamara@intel.com>
Subject: [dpdk-dev] [PATCH 1/6] interrupts: fix argument cannot be negative
Date: Mon, 1 Nov 2021 23:23:32 +0530 [thread overview]
Message-ID: <20211101175337.83358-1-hkalra@marvell.com> (raw)
This patch fixes coverity issues by adding a check for
negative event fd value.
Coverity issue: 373716,373699,373693,373688
Fixes: bbbac4cd6ed2 ("interrupts: remove direct access to interrupt handle")
Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
lib/eal/linux/eal_interrupts.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
index f72661e1f0..15a27a2abf 100644
--- a/lib/eal/linux/eal_interrupts.c
+++ b/lib/eal/linux/eal_interrupts.c
@@ -416,7 +416,7 @@ uio_intx_intr_disable(const struct rte_intr_handle *intr_handle)
/* use UIO config file descriptor for uio_pci_generic */
uio_cfg_fd = rte_intr_dev_fd_get(intr_handle);
- if (pread(uio_cfg_fd, &command_high, 1, 5) != 1) {
+ if (uio_cfg_fd < 0 || pread(uio_cfg_fd, &command_high, 1, 5) != 1) {
RTE_LOG(ERR, EAL,
"Error reading interrupts status for fd %d\n",
uio_cfg_fd);
@@ -442,7 +442,7 @@ uio_intx_intr_enable(const struct rte_intr_handle *intr_handle)
/* use UIO config file descriptor for uio_pci_generic */
uio_cfg_fd = rte_intr_dev_fd_get(intr_handle);
- if (pread(uio_cfg_fd, &command_high, 1, 5) != 1) {
+ if (uio_cfg_fd < 0 || pread(uio_cfg_fd, &command_high, 1, 5) != 1) {
RTE_LOG(ERR, EAL,
"Error reading interrupts status for fd %d\n",
uio_cfg_fd);
@@ -465,7 +465,8 @@ uio_intr_disable(const struct rte_intr_handle *intr_handle)
{
const int value = 0;
- if (write(rte_intr_fd_get(intr_handle), &value, sizeof(value)) < 0) {
+ if (rte_intr_fd_get(intr_handle) < 0 ||
+ write(rte_intr_fd_get(intr_handle), &value, sizeof(value)) < 0) {
RTE_LOG(ERR, EAL, "Error disabling interrupts for fd %d (%s)\n",
rte_intr_fd_get(intr_handle), strerror(errno));
return -1;
@@ -478,7 +479,8 @@ uio_intr_enable(const struct rte_intr_handle *intr_handle)
{
const int value = 1;
- if (write(rte_intr_fd_get(intr_handle), &value, sizeof(value)) < 0) {
+ if (rte_intr_fd_get(intr_handle) < 0 ||
+ write(rte_intr_fd_get(intr_handle), &value, sizeof(value)) < 0) {
RTE_LOG(ERR, EAL, "Error enabling interrupts for fd %d (%s)\n",
rte_intr_fd_get(intr_handle), strerror(errno));
return -1;
--
2.18.0
next reply other threads:[~2021-11-01 17:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-01 17:53 Harman Kalra [this message]
2021-11-01 17:53 ` [dpdk-dev] [PATCH 2/6] lib: " Harman Kalra
2021-11-01 17:53 ` [dpdk-dev] [PATCH 3/6] drivers: fix bad bit shift operation Harman Kalra
2021-11-02 1:22 ` Wang, Haiyue
2021-11-01 17:53 ` [dpdk-dev] [PATCH 4/6] drivers: fix argument cannot be negative Harman Kalra
2021-11-01 17:53 ` [dpdk-dev] [PATCH 5/6] drivers: fix improper use of negative value Harman Kalra
2021-11-01 17:53 ` [dpdk-dev] [PATCH 6/6] net/mlx4: fix dereference after null check Harman Kalra
2021-11-02 7:34 ` Slava Ovsiienko
2021-11-08 16:32 ` David Marchand
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=20211101175337.83358-1-hkalra@marvell.com \
--to=hkalra@marvell.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--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).