[PATCH 4.4 21/34] xfs: quota: check result of register_shrinker()

2018-03-02 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Aliaksei Karaliou 


[ Upstream commit 3a3882ff26fbdbaf5f7e13f6a0bccfbf7121041d ]

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 
[darrick: move xfs_qm_destroy_quotainos nearer xfs_qm_init_quotainos]
Reviewed-by: Darrick J. Wong 
Signed-off-by: Darrick J. Wong 

Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 fs/xfs/xfs_qm.c |   45 +
 1 file changed, 29 insertions(+), 16 deletions(-)

--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -47,7 +47,7 @@
 STATIC int xfs_qm_init_quotainos(xfs_mount_t *);
 STATIC int xfs_qm_init_quotainfo(xfs_mount_t *);
 
-
+STATIC voidxfs_qm_destroy_quotainos(xfs_quotainfo_t *qi);
 STATIC voidxfs_qm_dqfree_one(struct xfs_dquot *dqp);
 /*
  * We use the batch lookup interface to iterate over the dquots as it
@@ -660,9 +660,17 @@ xfs_qm_init_quotainfo(
qinf->qi_shrinker.scan_objects = xfs_qm_shrink_scan;
qinf->qi_shrinker.seeks = DEFAULT_SEEKS;
qinf->qi_shrinker.flags = SHRINKER_NUMA_AWARE;
-   register_shrinker(>qi_shrinker);
+
+   error = register_shrinker(>qi_shrinker);
+   if (error)
+   goto out_free_inos;
+
return 0;
 
+out_free_inos:
+   mutex_destroy(>qi_quotaofflock);
+   mutex_destroy(>qi_tree_lock);
+   xfs_qm_destroy_quotainos(qinf);
 out_free_lru:
list_lru_destroy(>qi_lru);
 out_free_qinf:
@@ -671,7 +679,6 @@ out_free_qinf:
return error;
 }
 
-
 /*
  * Gets called when unmounting a filesystem or when all quotas get
  * turned off.
@@ -688,19 +695,7 @@ xfs_qm_destroy_quotainfo(
 
unregister_shrinker(>qi_shrinker);
list_lru_destroy(>qi_lru);
-
-   if (qi->qi_uquotaip) {
-   IRELE(qi->qi_uquotaip);
-   qi->qi_uquotaip = NULL; /* paranoia */
-   }
-   if (qi->qi_gquotaip) {
-   IRELE(qi->qi_gquotaip);
-   qi->qi_gquotaip = NULL;
-   }
-   if (qi->qi_pquotaip) {
-   IRELE(qi->qi_pquotaip);
-   qi->qi_pquotaip = NULL;
-   }
+   xfs_qm_destroy_quotainos(qi);
mutex_destroy(>qi_tree_lock);
mutex_destroy(>qi_quotaofflock);
kmem_free(qi);
@@ -1563,6 +1558,24 @@ error_rele:
 }
 
 STATIC void
+xfs_qm_destroy_quotainos(
+   xfs_quotainfo_t *qi)
+{
+   if (qi->qi_uquotaip) {
+   IRELE(qi->qi_uquotaip);
+   qi->qi_uquotaip = NULL; /* paranoia */
+   }
+   if (qi->qi_gquotaip) {
+   IRELE(qi->qi_gquotaip);
+   qi->qi_gquotaip = NULL;
+   }
+   if (qi->qi_pquotaip) {
+   IRELE(qi->qi_pquotaip);
+   qi->qi_pquotaip = NULL;
+   }
+}
+
+STATIC void
 xfs_qm_dqfree_one(
struct xfs_dquot*dqp)
 {




[PATCH 4.4 21/34] xfs: quota: check result of register_shrinker()

2018-03-02 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Aliaksei Karaliou 


[ Upstream commit 3a3882ff26fbdbaf5f7e13f6a0bccfbf7121041d ]

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 
[darrick: move xfs_qm_destroy_quotainos nearer xfs_qm_init_quotainos]
Reviewed-by: Darrick J. Wong 
Signed-off-by: Darrick J. Wong 

Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 fs/xfs/xfs_qm.c |   45 +
 1 file changed, 29 insertions(+), 16 deletions(-)

--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -47,7 +47,7 @@
 STATIC int xfs_qm_init_quotainos(xfs_mount_t *);
 STATIC int xfs_qm_init_quotainfo(xfs_mount_t *);
 
-
+STATIC voidxfs_qm_destroy_quotainos(xfs_quotainfo_t *qi);
 STATIC voidxfs_qm_dqfree_one(struct xfs_dquot *dqp);
 /*
  * We use the batch lookup interface to iterate over the dquots as it
@@ -660,9 +660,17 @@ xfs_qm_init_quotainfo(
qinf->qi_shrinker.scan_objects = xfs_qm_shrink_scan;
qinf->qi_shrinker.seeks = DEFAULT_SEEKS;
qinf->qi_shrinker.flags = SHRINKER_NUMA_AWARE;
-   register_shrinker(>qi_shrinker);
+
+   error = register_shrinker(>qi_shrinker);
+   if (error)
+   goto out_free_inos;
+
return 0;
 
+out_free_inos:
+   mutex_destroy(>qi_quotaofflock);
+   mutex_destroy(>qi_tree_lock);
+   xfs_qm_destroy_quotainos(qinf);
 out_free_lru:
list_lru_destroy(>qi_lru);
 out_free_qinf:
@@ -671,7 +679,6 @@ out_free_qinf:
return error;
 }
 
-
 /*
  * Gets called when unmounting a filesystem or when all quotas get
  * turned off.
@@ -688,19 +695,7 @@ xfs_qm_destroy_quotainfo(
 
unregister_shrinker(>qi_shrinker);
list_lru_destroy(>qi_lru);
-
-   if (qi->qi_uquotaip) {
-   IRELE(qi->qi_uquotaip);
-   qi->qi_uquotaip = NULL; /* paranoia */
-   }
-   if (qi->qi_gquotaip) {
-   IRELE(qi->qi_gquotaip);
-   qi->qi_gquotaip = NULL;
-   }
-   if (qi->qi_pquotaip) {
-   IRELE(qi->qi_pquotaip);
-   qi->qi_pquotaip = NULL;
-   }
+   xfs_qm_destroy_quotainos(qi);
mutex_destroy(>qi_tree_lock);
mutex_destroy(>qi_quotaofflock);
kmem_free(qi);
@@ -1563,6 +1558,24 @@ error_rele:
 }
 
 STATIC void
+xfs_qm_destroy_quotainos(
+   xfs_quotainfo_t *qi)
+{
+   if (qi->qi_uquotaip) {
+   IRELE(qi->qi_uquotaip);
+   qi->qi_uquotaip = NULL; /* paranoia */
+   }
+   if (qi->qi_gquotaip) {
+   IRELE(qi->qi_gquotaip);
+   qi->qi_gquotaip = NULL;
+   }
+   if (qi->qi_pquotaip) {
+   IRELE(qi->qi_pquotaip);
+   qi->qi_pquotaip = NULL;
+   }
+}
+
+STATIC void
 xfs_qm_dqfree_one(
struct xfs_dquot*dqp)
 {