mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 10:14:55 +00:00
vboot_reference: fix CMOS writing for x86 platforms
VbCmosWrite should seek to correct offset before starting to write;
also fixed file handle leakage.
BUG=chromium-os:23000
TEST=crossystem recovery_request=1; echo $? # show: 0
crossystem recovery_request # show: 1
reboot # see recovery screen
Change-Id: I33bca8af2b351ba9b364309838df699a31bb543a
Reviewed-on: https://gerrit.chromium.org/gerrit/11756
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Gabe Black <gabeblack@chromium.org>
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
This commit is contained in:
@@ -112,12 +112,9 @@ static int VbCmosRead(int offs, size_t size, void *ptr) {
|
|||||||
VbFixCmosChecksum(f);
|
VbFixCmosChecksum(f);
|
||||||
res = fread(ptr, size, 1, f);
|
res = fread(ptr, size, 1, f);
|
||||||
}
|
}
|
||||||
if (1 != res) {
|
|
||||||
fclose(f);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
fclose(f);
|
||||||
|
return (1 == res) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -129,17 +126,19 @@ static int VbCmosWrite(int offs, size_t size, const void *ptr) {
|
|||||||
if (!f)
|
if (!f)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (0 != fseek(f, offs, SEEK_SET)) {
|
||||||
|
fclose(f);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
res = fwrite(ptr, size, 1, f);
|
res = fwrite(ptr, size, 1, f);
|
||||||
if (1 != res && errno == EIO && ferror(f)) {
|
if (1 != res && errno == EIO && ferror(f)) {
|
||||||
VbFixCmosChecksum(f);
|
VbFixCmosChecksum(f);
|
||||||
res = fwrite(ptr, size, 1, f);
|
res = fwrite(ptr, size, 1, f);
|
||||||
}
|
}
|
||||||
if (1 != res) {
|
|
||||||
fclose(f);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
fclose(f);
|
||||||
|
return (1 == res) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user