mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
dm table: fail dm_table_create on dm_round_up overflow
The dm_round_up function may overflow to zero. In this case, dm_table_create() must fail rather than go on to allocate an empty array with alloc_targets(). This fixes a possible memory corruption that could be caused by passing too large a number in "param->target_count". Signed-off-by: Mikulas Patocka <[email protected]> Signed-off-by: Mike Snitzer <[email protected]> Cc: [email protected]
This commit is contained in:
parent
230c83afdd
commit
5b2d06576c
1 changed files with 5 additions and 0 deletions
|
|
@ -200,6 +200,11 @@ int dm_table_create(struct dm_table **result, fmode_t mode,
|
|||
|
||||
num_targets = dm_round_up(num_targets, KEYS_PER_NODE);
|
||||
|
||||
if (!num_targets) {
|
||||
kfree(t);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (alloc_targets(t, num_targets)) {
|
||||
kfree(t);
|
||||
return -ENOMEM;
|
||||
|
|
|
|||
Loading…
Reference in a new issue