Skip to content

Commit 3a3882f

Browse files
Aliaksei Karalioudjwong
authored andcommitted
xfs: quota: check result of register_shrinker()
xfs_qm_init_quotainfo() does not check result of register_shrinker() which was tagged as __must_check recently, reported by sparse. Signed-off-by: Aliaksei Karaliou <[email protected]> [darrick: move xfs_qm_destroy_quotainos nearer xfs_qm_init_quotainos] Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 2196881 commit 3a3882f

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

fs/xfs/xfs_qm.c

Lines changed: 29 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,7 @@ 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);
739734
mutex_destroy(&qi->qi_tree_lock);
740735
mutex_destroy(&qi->qi_quotaofflock);
741736
kmem_free(qi);
@@ -1600,6 +1595,24 @@ xfs_qm_init_quotainos(
16001595
return error;
16011596
}
16021597

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+
16031616
STATIC void
16041617
xfs_qm_dqfree_one(
16051618
struct xfs_dquot *dqp)

0 commit comments

Comments
 (0)