aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Hocko <mhocko@suse.com>2017-11-23 11:13:40 -0500
committerDarrick J. Wong <darrick.wong@oracle.com>2017-11-28 11:57:11 -0500
commitd210a9874b8f6166579408131cb74495caff1958 (patch)
tree98f69c1ca0e3428c3f203eef300b9da08c6375e7
parent509955823cc9cc225c05673b1b83d70ca70c5c60 (diff)
xfs: fortify xfs_alloc_buftarg error handling
percpu_counter_init failure path doesn't clean up &btp->bt_lru list. Call list_lru_destroy in that error path. Similarly register_shrinker error path is not handled. While it is unlikely to trigger these error path, it is not impossible especially the later might fail with large NUMAs. Let's handle the failure to make the code more robust. Noticed-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Michal Hocko <mhocko@suse.com> Acked-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
-rw-r--r--fs/xfs/xfs_buf.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 4db6e8d780f6..4c6e86d861fd 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1815,22 +1815,27 @@ xfs_alloc_buftarg(
1815 btp->bt_daxdev = dax_dev; 1815 btp->bt_daxdev = dax_dev;
1816 1816
1817 if (xfs_setsize_buftarg_early(btp, bdev)) 1817 if (xfs_setsize_buftarg_early(btp, bdev))
1818 goto error; 1818 goto error_free;
1819 1819
1820 if (list_lru_init(&btp->bt_lru)) 1820 if (list_lru_init(&btp->bt_lru))
1821 goto error; 1821 goto error_free;
1822 1822
1823 if (percpu_counter_init(&btp->bt_io_count, 0, GFP_KERNEL)) 1823 if (percpu_counter_init(&btp->bt_io_count, 0, GFP_KERNEL))
1824 goto error; 1824 goto error_lru;
1825 1825
1826 btp->bt_shrinker.count_objects = xfs_buftarg_shrink_count; 1826 btp->bt_shrinker.count_objects = xfs_buftarg_shrink_count;
1827 btp->bt_shrinker.scan_objects = xfs_buftarg_shrink_scan; 1827 btp->bt_shrinker.scan_objects = xfs_buftarg_shrink_scan;
1828 btp->bt_shrinker.seeks = DEFAULT_SEEKS; 1828 btp->bt_shrinker.seeks = DEFAULT_SEEKS;
1829 btp->bt_shrinker.flags = SHRINKER_NUMA_AWARE; 1829 btp->bt_shrinker.flags = SHRINKER_NUMA_AWARE;
1830 register_shrinker(&btp->bt_shrinker); 1830 if (register_shrinker(&btp->bt_shrinker))
1831 goto error_pcpu;
1831 return btp; 1832 return btp;
1832 1833
1833error: 1834error_pcpu:
1835 percpu_counter_destroy(&btp->bt_io_count);
1836error_lru:
1837 list_lru_destroy(&btp->bt_lru);
1838error_free:
1834 kmem_free(btp); 1839 kmem_free(btp);
1835 return NULL; 1840 return NULL;
1836} 1841}