diff options
author | Wenchao Hao <haowenchao@huawei.com> | 2020-11-24 16:15:28 +0800 |
---|---|---|
committer | Wenchao Hao <haowenchao@huawei.com> | 2020-12-12 11:44:05 +0800 |
commit | caa45e53c9ba163238deae6a3c5f81b33e5be4a7 (patch) | |
tree | 2c054e851bccd23e549166bd6b87e28464e405f6 | |
parent | d18fd867116ba503fc1ba684469b30c07e41ee45 (diff) | |
download | open-iscsi-caa45e53c9ba163238deae6a3c5f81b33e5be4a7.tar.gz |
iscsiuio: Fix invalid parameter when call fstat()
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 <haowenchao@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
-rw-r--r-- | iscsiuio/src/unix/libs/bnx2x.c | 7 | ||||
-rw-r--r-- | iscsiuio/src/unix/libs/qedi.c | 7 |
2 files changed, 14 insertions, 0 deletions
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; |