Skip to content

Commit 654a7ae

Browse files
Baoli.Zhangvinodkoul
authored andcommitted
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>
1 parent f772ff5 commit 654a7ae

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

drivers/soundwire/generic_bandwidth_allocation.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,22 +308,23 @@ static int sdw_add_element_group_count(struct sdw_group *group,
308308
unsigned int *rates;
309309
unsigned int *lanes;
310310

311-
group->max_size += 1;
312311
rates = krealloc(group->rates,
313-
(sizeof(int) * group->max_size),
312+
sizeof(int) * (group->max_size + 1),
314313
GFP_KERNEL);
315314
if (!rates)
316315
return -ENOMEM;
317316

318317
group->rates = rates;
319318

320319
lanes = krealloc(group->lanes,
321-
(sizeof(int) * group->max_size),
320+
sizeof(int) * (group->max_size + 1),
322321
GFP_KERNEL);
323322
if (!lanes)
324323
return -ENOMEM;
325324

326325
group->lanes = lanes;
326+
327+
group->max_size += 1;
327328
}
328329

329330
group->rates[group->count] = rate;

0 commit comments

Comments
 (0)