|
|
@@ -190,14 +190,15 @@ static struct device *__nd_btt_create(struct nd_region *nd_region,
|
|
|
return NULL;
|
|
|
|
|
|
nd_btt->id = ida_simple_get(&nd_region->btt_ida, 0, 0, GFP_KERNEL);
|
|
|
- if (nd_btt->id < 0) {
|
|
|
- kfree(nd_btt);
|
|
|
- return NULL;
|
|
|
- }
|
|
|
+ if (nd_btt->id < 0)
|
|
|
+ goto out_nd_btt;
|
|
|
|
|
|
nd_btt->lbasize = lbasize;
|
|
|
- if (uuid)
|
|
|
+ if (uuid) {
|
|
|
uuid = kmemdup(uuid, 16, GFP_KERNEL);
|
|
|
+ if (!uuid)
|
|
|
+ goto out_put_id;
|
|
|
+ }
|
|
|
nd_btt->uuid = uuid;
|
|
|
dev = &nd_btt->dev;
|
|
|
dev_set_name(dev, "btt%d.%d", nd_region->id, nd_btt->id);
|
|
|
@@ -212,6 +213,13 @@ static struct device *__nd_btt_create(struct nd_region *nd_region,
|
|
|
return NULL;
|
|
|
}
|
|
|
return dev;
|
|
|
+
|
|
|
+out_put_id:
|
|
|
+ ida_simple_remove(&nd_region->btt_ida, nd_btt->id);
|
|
|
+
|
|
|
+out_nd_btt:
|
|
|
+ kfree(nd_btt);
|
|
|
+ return NULL;
|
|
|
}
|
|
|
|
|
|
struct device *nd_btt_create(struct nd_region *nd_region)
|