]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.120/xfs-quota-check-result-of-register_shrinker.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.120 / xfs-quota-check-result-of-register_shrinker.patch
CommitLineData
d996137a
GKH
1From foo@baz Wed Feb 28 16:19:30 CET 2018
2From: Aliaksei Karaliou <akaraliou.dev@gmail.com>
3Date: Thu, 21 Dec 2017 13:18:26 -0800
4Subject: xfs: quota: check result of register_shrinker()
5
6From: Aliaksei Karaliou <akaraliou.dev@gmail.com>
7
8
9[ Upstream commit 3a3882ff26fbdbaf5f7e13f6a0bccfbf7121041d ]
10
11xfs_qm_init_quotainfo() does not check result of register_shrinker()
12which was tagged as __must_check recently, reported by sparse.
13
14Signed-off-by: Aliaksei Karaliou <akaraliou.dev@gmail.com>
15[darrick: move xfs_qm_destroy_quotainos nearer xfs_qm_init_quotainos]
16Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
17Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
18
19Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
20Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21---
22 fs/xfs/xfs_qm.c | 45 +++++++++++++++++++++++++++++----------------
23 1 file changed, 29 insertions(+), 16 deletions(-)
24
25--- a/fs/xfs/xfs_qm.c
26+++ b/fs/xfs/xfs_qm.c
27@@ -47,7 +47,7 @@
28 STATIC int xfs_qm_init_quotainos(xfs_mount_t *);
29 STATIC int xfs_qm_init_quotainfo(xfs_mount_t *);
30
31-
32+STATIC void xfs_qm_destroy_quotainos(xfs_quotainfo_t *qi);
33 STATIC void xfs_qm_dqfree_one(struct xfs_dquot *dqp);
34 /*
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);
41+
42+ error = register_shrinker(&qinf->qi_shrinker);
43+ if (error)
44+ goto out_free_inos;
45+
46 return 0;
47
48+out_free_inos:
49+ mutex_destroy(&qinf->qi_quotaofflock);
50+ mutex_destroy(&qinf->qi_tree_lock);
51+ xfs_qm_destroy_quotainos(qinf);
52 out_free_lru:
53 list_lru_destroy(&qinf->qi_lru);
54 out_free_qinf:
55@@ -671,7 +679,6 @@ out_free_qinf:
56 return error;
57 }
58
59-
60 /*
61 * Gets called when unmounting a filesystem or when all quotas get
62 * turned off.
63@@ -688,19 +695,7 @@ xfs_qm_destroy_quotainfo(
64
65 unregister_shrinker(&qi->qi_shrinker);
66 list_lru_destroy(&qi->qi_lru);
67-
68- if (qi->qi_uquotaip) {
69- IRELE(qi->qi_uquotaip);
70- qi->qi_uquotaip = NULL; /* paranoia */
71- }
72- if (qi->qi_gquotaip) {
73- IRELE(qi->qi_gquotaip);
74- qi->qi_gquotaip = NULL;
75- }
76- if (qi->qi_pquotaip) {
77- IRELE(qi->qi_pquotaip);
78- qi->qi_pquotaip = NULL;
79- }
80+ xfs_qm_destroy_quotainos(qi);
81 mutex_destroy(&qi->qi_tree_lock);
82 mutex_destroy(&qi->qi_quotaofflock);
83 kmem_free(qi);
84@@ -1563,6 +1558,24 @@ error_rele:
85 }
86
87 STATIC void
88+xfs_qm_destroy_quotainos(
89+ xfs_quotainfo_t *qi)
90+{
91+ if (qi->qi_uquotaip) {
92+ IRELE(qi->qi_uquotaip);
93+ qi->qi_uquotaip = NULL; /* paranoia */
94+ }
95+ if (qi->qi_gquotaip) {
96+ IRELE(qi->qi_gquotaip);
97+ qi->qi_gquotaip = NULL;
98+ }
99+ if (qi->qi_pquotaip) {
100+ IRELE(qi->qi_pquotaip);
101+ qi->qi_pquotaip = NULL;
102+ }
103+}
104+
105+STATIC void
106 xfs_qm_dqfree_one(
107 struct xfs_dquot *dqp)
108 {