1 From foo@baz Wed Feb 28 16:19:30 CET 2018
2 From: Aliaksei Karaliou <akaraliou.dev@gmail.com>
3 Date: Thu, 21 Dec 2017 13:18:26 -0800
4 Subject: xfs: quota: check result of register_shrinker()
6 From: Aliaksei Karaliou <akaraliou.dev@gmail.com>
9 [ Upstream commit 3a3882ff26fbdbaf5f7e13f6a0bccfbf7121041d ]
11 xfs_qm_init_quotainfo() does not check result of register_shrinker()
12 which was tagged as __must_check recently, reported by sparse.
14 Signed-off-by: Aliaksei Karaliou <akaraliou.dev@gmail.com>
15 [darrick: move xfs_qm_destroy_quotainos nearer xfs_qm_init_quotainos]
16 Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
17 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
19 Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22 fs/xfs/xfs_qm.c | 45 +++++++++++++++++++++++++++++----------------
23 1 file changed, 29 insertions(+), 16 deletions(-)
28 STATIC int xfs_qm_init_quotainos(xfs_mount_t *);
29 STATIC int xfs_qm_init_quotainfo(xfs_mount_t *);
32 +STATIC void xfs_qm_destroy_quotainos(xfs_quotainfo_t *qi);
33 STATIC void xfs_qm_dqfree_one(struct xfs_dquot *dqp);
35 * We use the batch lookup interface to iterate over the dquots as it
36 @@ -660,9 +660,17 @@ xfs_qm_init_quotainfo(
37 qinf->qi_shrinker.scan_objects = xfs_qm_shrink_scan;
38 qinf->qi_shrinker.seeks = DEFAULT_SEEKS;
39 qinf->qi_shrinker.flags = SHRINKER_NUMA_AWARE;
40 - register_shrinker(&qinf->qi_shrinker);
42 + error = register_shrinker(&qinf->qi_shrinker);
49 + mutex_destroy(&qinf->qi_quotaofflock);
50 + mutex_destroy(&qinf->qi_tree_lock);
51 + xfs_qm_destroy_quotainos(qinf);
53 list_lru_destroy(&qinf->qi_lru);
55 @@ -671,7 +679,6 @@ out_free_qinf:
61 * Gets called when unmounting a filesystem or when all quotas get
63 @@ -688,19 +695,7 @@ xfs_qm_destroy_quotainfo(
65 unregister_shrinker(&qi->qi_shrinker);
66 list_lru_destroy(&qi->qi_lru);
68 - if (qi->qi_uquotaip) {
69 - IRELE(qi->qi_uquotaip);
70 - qi->qi_uquotaip = NULL; /* paranoia */
72 - if (qi->qi_gquotaip) {
73 - IRELE(qi->qi_gquotaip);
74 - qi->qi_gquotaip = NULL;
76 - if (qi->qi_pquotaip) {
77 - IRELE(qi->qi_pquotaip);
78 - qi->qi_pquotaip = NULL;
80 + xfs_qm_destroy_quotainos(qi);
81 mutex_destroy(&qi->qi_tree_lock);
82 mutex_destroy(&qi->qi_quotaofflock);
84 @@ -1563,6 +1558,24 @@ error_rele:
88 +xfs_qm_destroy_quotainos(
89 + xfs_quotainfo_t *qi)
91 + if (qi->qi_uquotaip) {
92 + IRELE(qi->qi_uquotaip);
93 + qi->qi_uquotaip = NULL; /* paranoia */
95 + if (qi->qi_gquotaip) {
96 + IRELE(qi->qi_gquotaip);
97 + qi->qi_gquotaip = NULL;
99 + if (qi->qi_pquotaip) {
100 + IRELE(qi->qi_pquotaip);
101 + qi->qi_pquotaip = NULL;
107 struct xfs_dquot *dqp)