[PATCH 03/12] iscsiuio: Fix invalid parameter when call fstat()

19 views
Skip to first unread message

Wenchao Hao

unread,
Dec 6, 2020, 8:55:26 PM12/6/20
to Lee Duncan, open-...@googlegroups.com, linfe...@huawei.com, Zhiqiang Liu, Wu Bo, Wenchao Hao
Both qedi_open() and bnx2x_open() perform 15 times retry
to make system call open() successful, while this retry
mechanism can not make sure open() can execute successfully.
So this patch verify return value of open(), if it is still
INVALID_FD just print error info and return the errno.

Signed-off-by: Wenchao Hao <haowe...@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhi...@huawei.com>
---
iscsiuio/src/unix/libs/bnx2x.c | 7 +++++++
iscsiuio/src/unix/libs/qedi.c | 7 +++++++
2 files changed, 14 insertions(+)

diff --git a/iscsiuio/src/unix/libs/bnx2x.c b/iscsiuio/src/unix/libs/bnx2x.c
index c5e7b71..0e326d4 100644
--- a/iscsiuio/src/unix/libs/bnx2x.c
+++ b/iscsiuio/src/unix/libs/bnx2x.c
@@ -751,6 +751,13 @@ static int bnx2x_open(nic_t *nic)
count++;
}
}
+ if (nic->fd == INVALID_FD) {
+ LOG_ERR(PFX "%s: Could not open device: %s, [%s]",
+ nic->log_name, nic->uio_device_name,
+ strerror(errno));
+ rc = errno;
+ goto open_error;
+ }
if (fstat(nic->fd, &uio_stat) < 0) {
LOG_ERR(PFX "%s: Could not fstat device", nic->log_name);
rc = -ENODEV;
diff --git a/iscsiuio/src/unix/libs/qedi.c b/iscsiuio/src/unix/libs/qedi.c
index 3414cb5..1af8d1b 100644
--- a/iscsiuio/src/unix/libs/qedi.c
+++ b/iscsiuio/src/unix/libs/qedi.c
@@ -517,6 +517,13 @@ static int qedi_open(nic_t *nic)
count++;
}
}
+ if (nic->fd == INVALID_FD) {
+ LOG_ERR(PFX "%s: Could not open device: %s, [%s]",
+ nic->log_name, nic->uio_device_name,
+ strerror(errno));
+ rc = errno;
+ goto open_error;
+ }
if (fstat(nic->fd, &uio_stat) < 0) {
LOG_ERR(PFX "%s: Could not fstat device", nic->log_name);
rc = -ENODEV;
--
2.27.0

Reply all
Reply to author
Forward
0 new messages