diff options
| author | Baoli.Zhang <baoli.zhang@linux.intel.com> | 2026-05-06 13:50:37 +0800 |
|---|---|---|
| committer | Vinod Koul <vkoul@kernel.org> | 2026-05-07 13:04:38 +0530 |
| commit | 35a5ab8ef7f0f00b30eab9d917f3f0f4a2bec5d6 (patch) | |
| tree | 4b16970fe2804bac3ad82a5d2ccf09787c6c029d /drivers/soundwire | |
| parent | 654a7ae10b2ee6b07d5d9193c1c5465410781908 (diff) | |
| download | linux-next-35a5ab8ef7f0f00b30eab9d917f3f0f4a2bec5d6.tar.gz linux-next-35a5ab8ef7f0f00b30eab9d917f3f0f4a2bec5d6.zip | |
soundwire: use krealloc_array to prevent integer overflow
Replace the use of krealloc() with krealloc_array() in
sdw_add_element_group_count to mitigate the risk of integer overflow during
memory allocation size calculation.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Baoli.Zhang <baoli.zhang@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260506055039.3751028-4-baoli.zhang@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/soundwire')
| -rw-r--r-- | drivers/soundwire/generic_bandwidth_allocation.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/soundwire/generic_bandwidth_allocation.c b/drivers/soundwire/generic_bandwidth_allocation.c index cd9ccbaf0e46..3575d69ce1c5 100644 --- a/drivers/soundwire/generic_bandwidth_allocation.c +++ b/drivers/soundwire/generic_bandwidth_allocation.c @@ -308,17 +308,15 @@ static int sdw_add_element_group_count(struct sdw_group *group, unsigned int *rates; unsigned int *lanes; - rates = krealloc(group->rates, - sizeof(int) * (group->max_size + 1), - GFP_KERNEL); + rates = krealloc_array(group->rates, group->max_size + 1, + sizeof(*group->rates), GFP_KERNEL); if (!rates) return -ENOMEM; group->rates = rates; - lanes = krealloc(group->lanes, - sizeof(int) * (group->max_size + 1), - GFP_KERNEL); + lanes = krealloc_array(group->lanes, group->max_size + 1, + sizeof(*group->lanes), GFP_KERNEL); if (!lanes) return -ENOMEM; |
