summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorweiping zhang <zhangweiping@didichuxing.com>2017-11-17 23:06:04 +0800
committerJens Axboe <axboe@kernel.dk>2017-11-19 11:02:13 -0700
commita0747a859ef6d3cc5b6cd50eb694499b78dd0025 (patch)
treec1402f908087e9d5b5564e72a3533137254fdb0a /mm
parent97f07697932e6faf2a708f7aef7cba8e6b0cab96 (diff)
downloadlinux-a0747a859ef6d3cc5b6cd50eb694499b78dd0025.tar.gz
linux-a0747a859ef6d3cc5b6cd50eb694499b78dd0025.tar.bz2
linux-a0747a859ef6d3cc5b6cd50eb694499b78dd0025.zip
bdi: add error handle for bdi_debug_register
In order to make error handle more cleaner we call bdi_debug_register before set state to WB_registered, that we can avoid call bdi_unregister in release_bdi(). Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: weiping zhang <zhangweiping@didichuxing.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'mm')
-rw-r--r--mm/backing-dev.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index b5f940ce0143..84b2dc76f140 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -882,10 +882,13 @@ int bdi_register_va(struct backing_dev_info *bdi, const char *fmt, va_list args)
if (IS_ERR(dev))
return PTR_ERR(dev);
+ if (bdi_debug_register(bdi, dev_name(dev))) {
+ device_destroy(bdi_class, dev->devt);
+ return -ENOMEM;
+ }
cgwb_bdi_register(bdi);
bdi->dev = dev;
- bdi_debug_register(bdi, dev_name(dev));
set_bit(WB_registered, &bdi->wb.state);
spin_lock_bh(&bdi_lock);