hwclock: close adjtime on write error [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
777fe9f512
commit
3fdb178370
|
@ -901,13 +901,18 @@ static int save_adjtime(const struct hwclock_control *ctl,
|
|||
}
|
||||
|
||||
if (!ctl->testing) {
|
||||
int rc;
|
||||
|
||||
fp = fopen(ctl->adj_file_name, "w");
|
||||
if (fp == NULL) {
|
||||
warn(_("cannot open %s"), ctl->adj_file_name);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (fputs(content, fp) < 0 || close_stream(fp) != 0) {
|
||||
rc = fputs(content, fp) < 0;
|
||||
rc += close_stream(fp);
|
||||
|
||||
if (rc) {
|
||||
warn(_("cannot update %s"), ctl->adj_file_name);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue