mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
cov: fix incorrect error check
Check for NULL pointer. Fix missing release on error path. Also dir_fd might be just != -1.
This commit is contained in:
parent
781bf867cc
commit
835e8f9d7a
@ -1404,7 +1404,7 @@ static void devices_file_backup(struct cmd_context *cmd, char *fc, char *fb, tim
|
|||||||
return;
|
return;
|
||||||
if (!dm_create_dir(dirpath))
|
if (!dm_create_dir(dirpath))
|
||||||
return;
|
return;
|
||||||
if ((dir = opendir(dirpath)) < 0)
|
if (!(dir = opendir(dirpath)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tm = localtime(tp);
|
tm = localtime(tp);
|
||||||
@ -1413,11 +1413,11 @@ static void devices_file_backup(struct cmd_context *cmd, char *fc, char *fb, tim
|
|||||||
/* system.devices-YYYYMMDD.HHMMSS.000N (fixed length 35) */
|
/* system.devices-YYYYMMDD.HHMMSS.000N (fixed length 35) */
|
||||||
if (dm_snprintf(path, sizeof(path), "%s/devices/backup/system.devices-%s.%04u",
|
if (dm_snprintf(path, sizeof(path), "%s/devices/backup/system.devices-%s.%04u",
|
||||||
cmd->system_dir, datetime_str, df_counter) < 0)
|
cmd->system_dir, datetime_str, df_counter) < 0)
|
||||||
return;
|
goto_out;
|
||||||
|
|
||||||
if (!(fp = fopen(path, "w+"))) {
|
if (!(fp = fopen(path, "w+"))) {
|
||||||
log_error("Failed to create backup file %s", path);
|
log_error("Failed to create backup file %s", path);
|
||||||
return;
|
goto out;
|
||||||
}
|
}
|
||||||
if (fputs(fc, fp) < 0) {
|
if (fputs(fc, fp) < 0) {
|
||||||
log_error("Failed to write backup file %s", path);
|
log_error("Failed to write backup file %s", path);
|
||||||
@ -1758,7 +1758,7 @@ out:
|
|||||||
free(fb);
|
free(fb);
|
||||||
if (fp)
|
if (fp)
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if (dir_fd > 0)
|
if (dir_fd != -1)
|
||||||
close(dir_fd);
|
close(dir_fd);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user