diff options
| -rw-r--r-- | drivers/nvdimm/btt_devs.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c index b72a303176c7..9486acc08402 100644 --- a/drivers/nvdimm/btt_devs.c +++ b/drivers/nvdimm/btt_devs.c | |||
| @@ -198,14 +198,15 @@ static struct device *__nd_btt_create(struct nd_region *nd_region, | |||
| 198 | return NULL; | 198 | return NULL; |
| 199 | 199 | ||
| 200 | nd_btt->id = ida_simple_get(&nd_region->btt_ida, 0, 0, GFP_KERNEL); | 200 | nd_btt->id = ida_simple_get(&nd_region->btt_ida, 0, 0, GFP_KERNEL); |
| 201 | if (nd_btt->id < 0) { | 201 | if (nd_btt->id < 0) |
| 202 | kfree(nd_btt); | 202 | goto out_nd_btt; |
| 203 | return NULL; | ||
| 204 | } | ||
| 205 | 203 | ||
| 206 | nd_btt->lbasize = lbasize; | 204 | nd_btt->lbasize = lbasize; |
| 207 | if (uuid) | 205 | if (uuid) { |
| 208 | uuid = kmemdup(uuid, 16, GFP_KERNEL); | 206 | uuid = kmemdup(uuid, 16, GFP_KERNEL); |
| 207 | if (!uuid) | ||
| 208 | goto out_put_id; | ||
| 209 | } | ||
| 209 | nd_btt->uuid = uuid; | 210 | nd_btt->uuid = uuid; |
| 210 | dev = &nd_btt->dev; | 211 | dev = &nd_btt->dev; |
| 211 | dev_set_name(dev, "btt%d.%d", nd_region->id, nd_btt->id); | 212 | dev_set_name(dev, "btt%d.%d", nd_region->id, nd_btt->id); |
| @@ -220,6 +221,13 @@ static struct device *__nd_btt_create(struct nd_region *nd_region, | |||
| 220 | return NULL; | 221 | return NULL; |
| 221 | } | 222 | } |
| 222 | return dev; | 223 | return dev; |
| 224 | |||
| 225 | out_put_id: | ||
| 226 | ida_simple_remove(&nd_region->btt_ida, nd_btt->id); | ||
| 227 | |||
| 228 | out_nd_btt: | ||
| 229 | kfree(nd_btt); | ||
| 230 | return NULL; | ||
| 223 | } | 231 | } |
| 224 | 232 | ||
| 225 | struct device *nd_btt_create(struct nd_region *nd_region) | 233 | struct device *nd_btt_create(struct nd_region *nd_region) |
