Skip to content

Commit 12e971b

Browse files
committed
Merge tag 'xfs-4.15-fixes-10' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull XFS fixes from Darrick Wong: "I have just a few fixes for bugs and resource cleanup problems this week: - Fix resource cleanup of failed quota initialization - Fix integer overflow problems wrt s_maxbytes" * tag 'xfs-4.15-fixes-10' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: xfs: fix s_maxbytes overflow problems xfs: quota: check result of register_shrinker() xfs: quota: fix missed destroy of qi_tree_lock
2 parents f842839 + b4d8ad7 commit 12e971b

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

fs/xfs/xfs_aops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ xfs_map_blocks(
399399
(ip->i_df.if_flags & XFS_IFEXTENTS));
400400
ASSERT(offset <= mp->m_super->s_maxbytes);
401401

402-
if ((xfs_ufsize_t)offset + count > mp->m_super->s_maxbytes)
402+
if (offset > mp->m_super->s_maxbytes - count)
403403
count = mp->m_super->s_maxbytes - offset;
404404
end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count);
405405
offset_fsb = XFS_B_TO_FSBT(mp, offset);
@@ -1312,7 +1312,7 @@ xfs_get_blocks(
13121312
lockmode = xfs_ilock_data_map_shared(ip);
13131313

13141314
ASSERT(offset <= mp->m_super->s_maxbytes);
1315-
if ((xfs_ufsize_t)offset + size > mp->m_super->s_maxbytes)
1315+
if (offset > mp->m_super->s_maxbytes - size)
13161316
size = mp->m_super->s_maxbytes - offset;
13171317
end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + size);
13181318
offset_fsb = XFS_B_TO_FSBT(mp, offset);

fs/xfs/xfs_iomap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ xfs_file_iomap_begin(
10061006
}
10071007

10081008
ASSERT(offset <= mp->m_super->s_maxbytes);
1009-
if ((xfs_fsize_t)offset + length > mp->m_super->s_maxbytes)
1009+
if (offset > mp->m_super->s_maxbytes - length)
10101010
length = mp->m_super->s_maxbytes - offset;
10111011
offset_fsb = XFS_B_TO_FSBT(mp, offset);
10121012
end_fsb = XFS_B_TO_FSB(mp, offset + length);

fs/xfs/xfs_qm.c

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
STATIC int xfs_qm_init_quotainos(xfs_mount_t *);
4949
STATIC int xfs_qm_init_quotainfo(xfs_mount_t *);
5050

51-
51+
STATIC void xfs_qm_destroy_quotainos(xfs_quotainfo_t *qi);
5252
STATIC void xfs_qm_dqfree_one(struct xfs_dquot *dqp);
5353
/*
5454
* We use the batch lookup interface to iterate over the dquots as it
@@ -695,9 +695,17 @@ xfs_qm_init_quotainfo(
695695
qinf->qi_shrinker.scan_objects = xfs_qm_shrink_scan;
696696
qinf->qi_shrinker.seeks = DEFAULT_SEEKS;
697697
qinf->qi_shrinker.flags = SHRINKER_NUMA_AWARE;
698-
register_shrinker(&qinf->qi_shrinker);
698+
699+
error = register_shrinker(&qinf->qi_shrinker);
700+
if (error)
701+
goto out_free_inos;
702+
699703
return 0;
700704

705+
out_free_inos:
706+
mutex_destroy(&qinf->qi_quotaofflock);
707+
mutex_destroy(&qinf->qi_tree_lock);
708+
xfs_qm_destroy_quotainos(qinf);
701709
out_free_lru:
702710
list_lru_destroy(&qinf->qi_lru);
703711
out_free_qinf:
@@ -706,7 +714,6 @@ xfs_qm_init_quotainfo(
706714
return error;
707715
}
708716

709-
710717
/*
711718
* Gets called when unmounting a filesystem or when all quotas get
712719
* turned off.
@@ -723,19 +730,8 @@ xfs_qm_destroy_quotainfo(
723730

724731
unregister_shrinker(&qi->qi_shrinker);
725732
list_lru_destroy(&qi->qi_lru);
726-
727-
if (qi->qi_uquotaip) {
728-
IRELE(qi->qi_uquotaip);
729-
qi->qi_uquotaip = NULL; /* paranoia */
730-
}
731-
if (qi->qi_gquotaip) {
732-
IRELE(qi->qi_gquotaip);
733-
qi->qi_gquotaip = NULL;
734-
}
735-
if (qi->qi_pquotaip) {
736-
IRELE(qi->qi_pquotaip);
737-
qi->qi_pquotaip = NULL;
738-
}
733+
xfs_qm_destroy_quotainos(qi);
734+
mutex_destroy(&qi->qi_tree_lock);
739735
mutex_destroy(&qi->qi_quotaofflock);
740736
kmem_free(qi);
741737
mp->m_quotainfo = NULL;
@@ -1599,6 +1595,24 @@ xfs_qm_init_quotainos(
15991595
return error;
16001596
}
16011597

1598+
STATIC void
1599+
xfs_qm_destroy_quotainos(
1600+
xfs_quotainfo_t *qi)
1601+
{
1602+
if (qi->qi_uquotaip) {
1603+
IRELE(qi->qi_uquotaip);
1604+
qi->qi_uquotaip = NULL; /* paranoia */
1605+
}
1606+
if (qi->qi_gquotaip) {
1607+
IRELE(qi->qi_gquotaip);
1608+
qi->qi_gquotaip = NULL;
1609+
}
1610+
if (qi->qi_pquotaip) {
1611+
IRELE(qi->qi_pquotaip);
1612+
qi->qi_pquotaip = NULL;
1613+
}
1614+
}
1615+
16021616
STATIC void
16031617
xfs_qm_dqfree_one(
16041618
struct xfs_dquot *dqp)

0 commit comments

Comments
 (0)