Skip to content

Commit 0d16daa

Browse files
charleskeepaxbroonie
authored andcommitted
ASoC: SDCA: Use __free() to manage local buffers
Use the cleanup.h helpers to manage some local buffers, this cleans up the error paths a little. Signed-off-by: Charles Keepax <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 988adcb commit 0d16daa

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

sound/soc/sdca/sdca_functions.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -913,9 +913,9 @@ static int find_sdca_entity_pde(struct device *dev,
913913
{
914914
static const int mult_delay = 3;
915915
struct sdca_entity_pde *power = &entity->pde;
916+
u32 *delay_list __free(kfree) = NULL;
916917
struct sdca_pde_delay *delays;
917918
int num_delays;
918-
u32 *delay_list;
919919
int i, j;
920920

921921
num_delays = fwnode_property_count_u32(entity_node,
@@ -962,8 +962,6 @@ static int find_sdca_entity_pde(struct device *dev,
962962
power->num_max_delay = num_delays;
963963
power->max_delay = delays;
964964

965-
kfree(delay_list);
966-
967965
return 0;
968966
}
969967

@@ -1022,8 +1020,8 @@ static int find_sdca_entities(struct device *dev,
10221020
struct fwnode_handle *function_node,
10231021
struct sdca_function_data *function)
10241022
{
1023+
u32 *entity_list __free(kfree) = NULL;
10251024
struct sdca_entity *entities;
1026-
u32 *entity_list;
10271025
int num_entities;
10281026
int i, ret;
10291027

@@ -1054,8 +1052,6 @@ static int find_sdca_entities(struct device *dev,
10541052
for (i = 0; i < num_entities; i++)
10551053
entities[i].id = entity_list[i];
10561054

1057-
kfree(entity_list);
1058-
10591055
/* now read subproperties */
10601056
for (i = 0; i < num_entities; i++) {
10611057
char entity_property[SDCA_PROPERTY_LENGTH];
@@ -1170,8 +1166,8 @@ static int find_sdca_entity_connection_pde(struct device *dev,
11701166
struct sdca_entity *entity)
11711167
{
11721168
struct sdca_entity_pde *power = &entity->pde;
1169+
u32 *managed_list __free(kfree) = NULL;
11731170
struct sdca_entity **managed;
1174-
u32 *managed_list;
11751171
int num_managed;
11761172
int i;
11771173

@@ -1205,15 +1201,12 @@ static int find_sdca_entity_connection_pde(struct device *dev,
12051201
if (!managed[i]) {
12061202
dev_err(dev, "%s: failed to find entity with id %#x\n",
12071203
entity->label, managed_list[i]);
1208-
kfree(managed_list);
12091204
return -EINVAL;
12101205
}
12111206

12121207
dev_info(dev, "%s -> %s\n", managed[i]->label, entity->label);
12131208
}
12141209

1215-
kfree(managed_list);
1216-
12171210
power->num_managed = num_managed;
12181211
power->managed = managed;
12191212

@@ -1453,9 +1446,9 @@ static int find_sdca_clusters(struct device *dev,
14531446
struct fwnode_handle *function_node,
14541447
struct sdca_function_data *function)
14551448
{
1449+
u32 *cluster_list __free(kfree) = NULL;
14561450
struct sdca_cluster *clusters;
14571451
int num_clusters;
1458-
u32 *cluster_list;
14591452
int i, ret;
14601453

14611454
num_clusters = fwnode_property_count_u32(function_node, "mipi-sdca-cluster-id-list");
@@ -1484,8 +1477,6 @@ static int find_sdca_clusters(struct device *dev,
14841477
for (i = 0; i < num_clusters; i++)
14851478
clusters[i].id = cluster_list[i];
14861479

1487-
kfree(cluster_list);
1488-
14891480
/* now read subproperties */
14901481
for (i = 0; i < num_clusters; i++) {
14911482
char cluster_property[SDCA_PROPERTY_LENGTH];

0 commit comments

Comments
 (0)