|
|
d4b218 |
commit 5b7506198a6872764a51e32363e219916e1e592e
|
|
|
d4b218 |
Author: Minwoo Im <minwoo.im@samsung.com>
|
|
|
d4b218 |
Date: Wed Apr 24 01:48:58 2019 +0100
|
|
|
d4b218 |
|
|
|
d4b218 |
ioctl: Fix wrong return case of get_property
|
|
|
d4b218 |
|
|
|
d4b218 |
If get_property_helper() succeeds in the first time, and then fails in
|
|
|
d4b218 |
the next time, then the ret value will not be updated to an error value.
|
|
|
d4b218 |
This patch removes 'ret' variable to make 'err' to return being updated
|
|
|
d4b218 |
everytime get_property_helper() invoked.
|
|
|
d4b218 |
|
|
|
d4b218 |
Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
|
|
|
d4b218 |
|
|
|
d4b218 |
diff --git a/nvme-ioctl.c b/nvme-ioctl.c
|
|
|
d4b218 |
index 16fdc66..75bf9fa 100644
|
|
|
d4b218 |
--- a/nvme-ioctl.c
|
|
|
d4b218 |
+++ b/nvme-ioctl.c
|
|
|
d4b218 |
@@ -612,7 +612,7 @@ int nvme_get_property(int fd, int offset, uint64_t *value)
|
|
|
d4b218 |
int nvme_get_properties(int fd, void **pbar)
|
|
|
d4b218 |
{
|
|
|
d4b218 |
int offset, advance;
|
|
|
d4b218 |
- int err, ret = -EINVAL;
|
|
|
d4b218 |
+ int err;
|
|
|
d4b218 |
int size = getpagesize();
|
|
|
d4b218 |
|
|
|
d4b218 |
*pbar = malloc(size);
|
|
|
d4b218 |
@@ -624,15 +624,13 @@ int nvme_get_properties(int fd, void **pbar)
|
|
|
d4b218 |
memset(*pbar, 0xff, size);
|
|
|
d4b218 |
for (offset = NVME_REG_CAP; offset <= NVME_REG_CMBSZ; offset += advance) {
|
|
|
d4b218 |
err = get_property_helper(fd, offset, *pbar + offset, &advance);
|
|
|
d4b218 |
- if (!err)
|
|
|
d4b218 |
- ret = 0;
|
|
|
d4b218 |
- else {
|
|
|
d4b218 |
+ if (err) {
|
|
|
d4b218 |
free(*pbar);
|
|
|
d4b218 |
break;
|
|
|
d4b218 |
}
|
|
|
d4b218 |
}
|
|
|
d4b218 |
|
|
|
d4b218 |
- return ret;
|
|
|
d4b218 |
+ return err;
|
|
|
d4b218 |
}
|
|
|
d4b218 |
|
|
|
d4b218 |
int nvme_set_property(int fd, int offset, int value)
|