mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
dm space map metadata: fix 'struct sm_metadata' leak on failed create
In dm_sm_metadata_create() we temporarily change the dm_space_map operations from 'ops' (whose .destroy function deallocates the sm_metadata) to 'bootstrap_ops' (whose .destroy function doesn't). If dm_sm_metadata_create() fails in sm_ll_new_metadata() or sm_ll_extend(), it exits back to dm_tm_create_internal(), which calls dm_sm_destroy() with the intention of freeing the sm_metadata, but it doesn't (because the dm_space_map operations is still set to 'bootstrap_ops'). Fix this by setting the dm_space_map operations back to 'ops' if dm_sm_metadata_create() fails when it is set to 'bootstrap_ops'. Signed-off-by: Benjamin Marzinski <[email protected]> Acked-by: Joe Thornber <[email protected]> Signed-off-by: Mike Snitzer <[email protected]> Cc: [email protected]
This commit is contained in:
parent
58fc4fedee
commit
314c25c56c
1 changed files with 6 additions and 8 deletions
|
|
@ -775,16 +775,14 @@ int dm_sm_metadata_create(struct dm_space_map *sm,
|
|||
memcpy(&smm->sm, &bootstrap_ops, sizeof(smm->sm));
|
||||
|
||||
r = sm_ll_new_metadata(&smm->ll, tm);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
if (nr_blocks > DM_SM_METADATA_MAX_BLOCKS)
|
||||
nr_blocks = DM_SM_METADATA_MAX_BLOCKS;
|
||||
r = sm_ll_extend(&smm->ll, nr_blocks);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
if (!r) {
|
||||
if (nr_blocks > DM_SM_METADATA_MAX_BLOCKS)
|
||||
nr_blocks = DM_SM_METADATA_MAX_BLOCKS;
|
||||
r = sm_ll_extend(&smm->ll, nr_blocks);
|
||||
}
|
||||
memcpy(&smm->sm, &ops, sizeof(smm->sm));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
/*
|
||||
* Now we need to update the newly created data structures with the
|
||||
|
|
|
|||
Loading…
Reference in a new issue