summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlava Pestov <sp@daterainc.com>2015-02-03 13:31:54 -0800
committerKent Overstreet <kmo@daterainc.com>2015-02-12 23:43:47 -0800
commitbbe83d0d7c8be022dbd96603360fbe8824325863 (patch)
tree7cb1e2f27c9d7bfda34b1ff47d42bc88dd0eb5a7
parenta6468f75c3dba977053abee4a081b0cd954b296a (diff)
bcache: fix init error path
If cache_set_alloc() fails before we add ourselves to sysfs, we would end up calling kobject_del() on a kobject that hasn't been added yet. This was exposed by the new init fault added recently. Change-Id: I8e913ceb6eab59a609f2087c13b6d96fe0a1914c
-rw-r--r--drivers/md/bcache/super.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 1b4cfaf29446..e1124224653a 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -796,7 +796,8 @@ static void cache_set_flush(struct closure *cl)
bch_cache_accounting_destroy(&c->accounting);
kobject_put(&c->internal);
- kobject_del(&c->kobj);
+ if (c->kobj.state_in_sysfs)
+ kobject_del(&c->kobj);
closure_return(cl);
}