Nikolai Artemiev has uploaded this change for review.

View Change

linux_mtd: check ioctl() return value properly

Make the linux_mtd driver treat any negative return value from the
MEMERASE ioctl as an error. Previously it only treated -1 as an error.

BUG=none
BRANCH=none
TEST=builds

Change-Id: I40cfbdee2ab608fbe6c17d9cac6ec53ff224d9a4
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
---
M linux_mtd.c
1 file changed, 5 insertions(+), 3 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/96/60996/1
diff --git a/linux_mtd.c b/linux_mtd.c
index 04eccde..9d80a51 100644
--- a/linux_mtd.c
+++ b/linux_mtd.c
@@ -286,9 +286,11 @@
.length = data->erasesize,
};

- if (ioctl(fileno(data->dev_fp), MEMERASE, &erase_info) == -1) {
- msg_perr("%s: ioctl: %s\n", __func__, strerror(errno));
- return 1;
+ int ret = ioctl(fileno(data->dev_fp), MEMERASE, &erase_info);
+ if (ret < 0) {
+ msg_perr("%s: MEMERASE ioctl call returned %d, error: %s\n",
+ __func__, ret, strerror(errno));
+ return 1;
}
}


To view, visit change 60996. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I40cfbdee2ab608fbe6c17d9cac6ec53ff224d9a4
Gerrit-Change-Number: 60996
Gerrit-PatchSet: 1
Gerrit-Owner: Nikolai Artemiev <nartemiev@google.com>
Gerrit-MessageType: newchange