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 <[email protected]>
Signed-off-by: Zhiqiang Liu <[email protected]>
---
 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

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/open-iscsi/20201207015410.48488-4-haowenchao%40huawei.com.

Reply via email to