ufs_trunc_branch(): never call with offsets != NULL && depth2 == 0
For calls in __ufs_truncate_blocks() it's just a matter of not incrementing offsets[0] and not making that call - immediately following loop will be executed one extra time and we'll be just fine. For recursive call in ufs_trunc_branch() itself, just assing NULL to offsets if we would be about to make such call. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
42432739b5
commit
97e0f8f87c
1 changed files with 6 additions and 3 deletions
|
@ -1075,7 +1075,7 @@ static void ufs_trunc_branch(struct inode *inode, unsigned *offsets, int depth2,
|
||||||
struct ufs_inode_info *ufsi = UFS_I(inode);
|
struct ufs_inode_info *ufsi = UFS_I(inode);
|
||||||
struct ufs_buffer_head *ubh;
|
struct ufs_buffer_head *ubh;
|
||||||
u64 tmp;
|
u64 tmp;
|
||||||
bool free_it = !offsets || !depth2;
|
bool free_it = !offsets;
|
||||||
unsigned from = offsets ? *offsets++ : 0;
|
unsigned from = offsets ? *offsets++ : 0;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
@ -1091,9 +1091,11 @@ static void ufs_trunc_branch(struct inode *inode, unsigned *offsets, int depth2,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (--depth) {
|
if (--depth) {
|
||||||
|
if (!--depth2)
|
||||||
|
offsets = NULL;
|
||||||
for (i = from ; i < uspi->s_apb ; i++, offsets = NULL) {
|
for (i = from ; i < uspi->s_apb ; i++, offsets = NULL) {
|
||||||
void *ind = ubh_get_data_ptr(uspi, ubh, i);
|
void *ind = ubh_get_data_ptr(uspi, ubh, i);
|
||||||
ufs_trunc_branch(inode, offsets, depth2 - 1, depth, ind);
|
ufs_trunc_branch(inode, offsets, depth2, depth, ind);
|
||||||
ubh_mark_buffer_dirty(ubh);
|
ubh_mark_buffer_dirty(ubh);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1237,7 +1239,8 @@ static void __ufs_truncate_blocks(struct inode *inode)
|
||||||
ufs_trunc_direct(inode);
|
ufs_trunc_direct(inode);
|
||||||
offsets[0] = UFS_IND_BLOCK;
|
offsets[0] = UFS_IND_BLOCK;
|
||||||
} else {
|
} else {
|
||||||
ufs_trunc_branch(inode, offsets + 1, depth2, depth - 1,
|
if (depth2)
|
||||||
|
ufs_trunc_branch(inode, offsets + 1, depth2, depth - 1,
|
||||||
ufs_get_direct_data_ptr(uspi, ufsi, offsets[0]++));
|
ufs_get_direct_data_ptr(uspi, ufsi, offsets[0]++));
|
||||||
}
|
}
|
||||||
for (i = offsets[0]; i <= UFS_TIND_BLOCK; i++) {
|
for (i = offsets[0]; i <= UFS_TIND_BLOCK; i++) {
|
||||||
|
|
Loading…
Reference in a new issue