mbcache: fix to detect failure of register_shrinker
PATCH 1/1 mbcache: fix to detect failure of register_shrinker
From: Chao Yu <[email protected]>
register_shrinker in mb_cache_create may fail due to no memory. This patch fixes to do the check of return value of register_shrinker and handle the error case, otherwise mb_cache_create may return with no error, but losing the inner shrinker.
--- fs/mbcache.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/mbcache.c +5 -1
@@ -366,7 +366,11 @@ struct mb_cache *mb_cache_create(int bucket_bits) cache->c_shrink.count_objects = mb_cache_count; cache->c_shrink.scan_objects = mb_cache_scan; cache->c_shrink.seeks =DEFAULT_SEEKS ; -register_shrinker (&cache->c_shrink); +if (register_shrinker (&cache->c_shrink)) { +kfree (cache->c_hash); +kfree (cache); + goto err_out; + }INIT_WORK (&cache->c_shrink_work, mb_cache_shrink_worker);
Signature · 1 line
2.7.2
Quoted 8 lines · Chao Yu
From: Chao Yu <[email protected]>
register_shrinkerinmb_cache_createmay fail due to no memory. This patch fixes to do the check of return value ofregister_shrinkerand handle the error case, otherwisemb_cache_createmay return with no error, but losing the inner shrinker.Signed-off-by Chao Yu <[email protected]>
Thanks for fixing this. The patch looks good. You can add:
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Theodore Ts'o
AppliedQuoted 9 lines · Chao Yu
From: Chao Yu <[email protected]>
register_shrinkerinmb_cache_createmay fail due to no memory. This patch fixes to do the check of return value ofregister_shrinkerand handle the error case, otherwisemb_cache_createmay return with no error, but losing the inner shrinker.Signed-off-by Chao Yu <[email protected]>Reviewed-by Jan Kara <[email protected]>
Applied, thanks. (Apologies for the delay; this patch slipped through the cracks.)
- Ted
Quoted 8 lines · Theodore Ts'o
Quoted 7 lines · Chao Yu
From: Chao Yu <[email protected]>
register_shrinkerinmb_cache_createmay fail due to no memory. This patch fixes to do the check of return value ofregister_shrinkerand handle the error case, otherwisemb_cache_createmay return with no error, but losing the inner shrinker.
Quoted 5 lines
Quoted 2 lines
Signed-off-by Chao Yu <[email protected]>Reviewed-by Jan Kara <[email protected]>Applied, thanks. (Apologies for the delay; this patch slipped through the cracks.)
Ping, didn't see it in mainline, is this patch still under testing now?
Quoted 3 lines
- Ted
Quoted 9 lines · Chao Yu
Quoted 8 lines · Theodore Ts'o
Quoted 7 lines · Chao Yu
From: Chao Yu <[email protected]>
register_shrinkerinmb_cache_createmay fail due to no memory. This patch fixes to do the check of return value ofregister_shrinkerand handle the error case, otherwisemb_cache_createmay return with no error, but losing the inner shrinker.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by Chao Yu <[email protected]>Reviewed-by Jan Kara <[email protected]>Applied, thanks. (Apologies for the delay; this patch slipped through the cracks.)
Ping, didn't see it in mainline, is this patch still under testing now?
I'm sorry, I'm not sure how it got dropped, but it's not in mainline and I'm not sure how it got dropped from the ext4 tree.
It's now queued up in the dev tree.
Thanks for checking back,
- Ted
Quoted 16 lines · Theodore Ts'o
Quoted 15 lines · Chao Yu
Quoted 13 lines · Theodore Ts'o
Quoted 9 lines · Chao Yu
From: Chao Yu <[email protected]>
register_shrinkerinmb_cache_createmay fail due to no memory. This patch fixes to do the check of return value ofregister_shrinkerand handle the error case, otherwisemb_cache_createmay return with no error, but losing the inner shrinker.Signed-off-by Chao Yu <[email protected]>Reviewed-by Jan Kara <[email protected]>Applied, thanks. (Apologies for the delay; this patch slipped through the cracks.)
Quoted 8 lines
Quoted 1 line
Ping, didn't see it in mainline, is this patch still under testing now?
I'm sorry, I'm not sure how it got dropped, but it's not in mainline and I'm not sure how it got dropped from the ext4 tree.
It's now queued up in the dev tree.
Thanks for checking back,
Thanks for merging! ;)
Quoted 3 lines
- Ted