mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
soundwire: increase group->max_size after allocation
Only update `group->max_size` after both allocations succeed to avoid leaving the group's state inconsistent if one allocation fails. 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-3-baoli.zhang@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
f772ff5a0e
commit
654a7ae10b
|
|
@ -308,9 +308,8 @@ static int sdw_add_element_group_count(struct sdw_group *group,
|
|||
unsigned int *rates;
|
||||
unsigned int *lanes;
|
||||
|
||||
group->max_size += 1;
|
||||
rates = krealloc(group->rates,
|
||||
(sizeof(int) * group->max_size),
|
||||
sizeof(int) * (group->max_size + 1),
|
||||
GFP_KERNEL);
|
||||
if (!rates)
|
||||
return -ENOMEM;
|
||||
|
|
@ -318,12 +317,14 @@ static int sdw_add_element_group_count(struct sdw_group *group,
|
|||
group->rates = rates;
|
||||
|
||||
lanes = krealloc(group->lanes,
|
||||
(sizeof(int) * group->max_size),
|
||||
sizeof(int) * (group->max_size + 1),
|
||||
GFP_KERNEL);
|
||||
if (!lanes)
|
||||
return -ENOMEM;
|
||||
|
||||
group->lanes = lanes;
|
||||
|
||||
group->max_size += 1;
|
||||
}
|
||||
|
||||
group->rates[group->count] = rate;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user