mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 04:37:32 -04:00
nvdimm/btt: Free arenas on btt_init() error paths
The arenas allocated by discover_arenas() or create_arenas() are not
freed on some error paths in btt_init(). This leaks memory when BTT
initialization fails.
Call free_arenas() from the affected error paths to release the
allocations.
[ as: commit message and log edits ]
Fixes: 5212e11fde ("nd_btt: atomic sector updates")
Cc: stable@vger.kernel.org
Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Link: https://patch.msgid.link/20260519-nvdimmleaks-v1-2-592300fb7a43@cse.iitm.ac.in
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
This commit is contained in:
committed by
Alison Schofield
parent
13fe4cd9dd
commit
1a6b6442a9
@@ -1592,7 +1592,7 @@ static struct btt *btt_init(struct nd_btt *nd_btt, unsigned long long rawsize,
|
||||
if (btt->init_state != INIT_READY && nd_region->ro) {
|
||||
dev_warn(dev, "%s is read-only, unable to init btt metadata\n",
|
||||
dev_name(&nd_region->dev));
|
||||
return NULL;
|
||||
goto err;
|
||||
} else if (btt->init_state != INIT_READY) {
|
||||
btt->num_arenas = (rawsize / ARENA_MAX_SIZE) +
|
||||
((rawsize % ARENA_MAX_SIZE) ? 1 : 0);
|
||||
@@ -1602,25 +1602,28 @@ static struct btt *btt_init(struct nd_btt *nd_btt, unsigned long long rawsize,
|
||||
ret = create_arenas(btt);
|
||||
if (ret) {
|
||||
dev_info(dev, "init: create_arenas: %d\n", ret);
|
||||
return NULL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = btt_meta_init(btt);
|
||||
if (ret) {
|
||||
dev_err(dev, "init: error in meta_init: %d\n", ret);
|
||||
return NULL;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
ret = btt_blk_init(btt);
|
||||
if (ret) {
|
||||
dev_err(dev, "init: error in blk_init: %d\n", ret);
|
||||
return NULL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
btt_debugfs_init(btt);
|
||||
|
||||
return btt;
|
||||
err:
|
||||
free_arenas(btt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user