ntfs_attr_rm(): fix inconsistent deallocation of *na; adapt its users

master N2006_11_08_220332
szaka 2006-11-08 20:00:28 +00:00
parent 342e2d7af6
commit 13ab497b7c
3 changed files with 22 additions and 22 deletions

View File

@ -3080,15 +3080,13 @@ add_attr_record:
(val && (ntfs_attr_pwrite(na, 0, size, val) != size))) {
err = errno;
ntfs_log_trace("Failed to initialize just added attribute.\n");
if (ntfs_attr_rm(na)) {
if (ntfs_attr_rm(na))
ntfs_log_trace("Failed to remove just added attribute. "
"Probably leaving inconstant metadata.\n");
ntfs_attr_close(na);
}
ntfs_attr_close(na);
goto err_out;
}
ntfs_attr_close(na);
/* Done !*/
return 0;
rm_attr_err_out:
@ -3164,9 +3162,6 @@ int ntfs_attr_rm(ntfs_attr *na)
ret = -1;
}
/* Throw away now non-exist attribute. */
ntfs_attr_close(na);
/* Done. */
return ret;
}

View File

@ -1230,10 +1230,13 @@ err_out:
ntfs_log_perror("Failed to open SD (0x50) attribute of "
" inode 0x%llx. Run chkdsk.\n",
(unsigned long long)ni->mft_no);
else if (ntfs_attr_rm(na))
ntfs_log_perror("Failed to remove SD (0x50) attribute "
"of inode 0x%llx. Run chkdsk.\n",
(unsigned long long)ni->mft_no);
else {
if (ntfs_attr_rm(na))
ntfs_log_perror("Failed to remove SD (0x50) "
"attribute of inode 0x%llx",
(unsigned long long)ni->mft_no);
ntfs_attr_close(na);
}
}
if (rollback_data) {
ntfs_attr *na;
@ -1243,10 +1246,14 @@ err_out:
ntfs_log_perror("Failed to open data attribute of "
" inode 0x%llx. Run chkdsk.\n",
(unsigned long long)ni->mft_no);
else if (ntfs_attr_rm(na))
ntfs_log_perror("Failed to remove data attribute of "
"inode 0x%llx. Run chkdsk.\n",
(unsigned long long)ni->mft_no);
else {
if (ntfs_attr_rm(na))
ntfs_log_perror("Failed to remove data "
"attribute of inode 0x%llx",
(unsigned long long)ni->mft_no);
ntfs_attr_close(na);
}
}
/*
* Free extent MFT records (should not exist any with current

View File

@ -1016,10 +1016,10 @@ static int ntfs_fuse_rm_stream(const char *path, ntfschar *stream_name,
res = -errno;
goto exit;
}
if (ntfs_attr_rm(na)) {
if (ntfs_attr_rm(na))
res = -errno;
ntfs_attr_close(na);
}
ntfs_attr_close(na);
exit:
if (ntfs_inode_close(ni))
ntfs_log_perror("Failed to close inode");
@ -1478,11 +1478,9 @@ static int ntfs_fuse_removexattr(const char *path, const char *name)
ntfs_fuse_mark_free_space_outdated();
if (ntfs_attr_rm(na))
res = -errno;
else
na = NULL;
ntfs_attr_close(na);
exit:
if (na)
ntfs_attr_close(na);
free(lename);
if (ntfs_inode_close(ni))
ntfs_log_perror("Failed to close inode");