Archived
161 lines
5.6 KiB
Diff
161 lines
5.6 KiB
Diff
From 917d5770485e4ccd73f1123e2032a220c021bb56 Mon Sep 17 00:00:00 2001
|
|
From: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
|
|
Date: Wed, 3 Dec 2025 17:12:40 +0100
|
|
Subject: [PATCH 01/17] ASoC: SDCA: functions: Fix confusing cleanup.h syntax
|
|
|
|
Initializing automatic __free variables to NULL without need (e.g.
|
|
branches with different allocations), followed by actual allocation is
|
|
in contrary to explicit coding rules guiding cleanup.h:
|
|
|
|
"Given that the "__free(...) = NULL" pattern for variables defined at
|
|
the top of the function poses this potential interdependency problem the
|
|
recommendation is to always define and assign variables in one statement
|
|
and not group variable definitions at the top of the function when
|
|
__free() is used."
|
|
|
|
Code does not have a bug, but is less readable and uses discouraged
|
|
coding practice, so fix that by moving declaration to the place of
|
|
assignment.
|
|
|
|
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
|
|
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
|
|
Link: https://patch.msgid.link/20251203-asoc-wrong-cleanup-h-continued-v1-3-5142be4874fb@oss.qualcomm.com
|
|
Signed-off-by: Mark Brown <broonie@kernel.org>
|
|
---
|
|
sound/soc/sdca/sdca_functions.c | 28 ++++++++++++++--------------
|
|
1 file changed, 14 insertions(+), 14 deletions(-)
|
|
|
|
diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c
|
|
index e86004c9dea0..b26884fc2a98 100644
|
|
--- a/sound/soc/sdca/sdca_functions.c
|
|
+++ b/sound/soc/sdca/sdca_functions.c
|
|
@@ -1180,7 +1180,6 @@ static int find_sdca_entity_pde(struct device *dev,
|
|
{
|
|
static const int mult_delay = 3;
|
|
struct sdca_entity_pde *power = &entity->pde;
|
|
- u32 *delay_list __free(kfree) = NULL;
|
|
struct sdca_pde_delay *delays;
|
|
int num_delays;
|
|
int i, j;
|
|
@@ -1201,7 +1200,8 @@ static int find_sdca_entity_pde(struct device *dev,
|
|
return -EINVAL;
|
|
}
|
|
|
|
- delay_list = kcalloc(num_delays, sizeof(*delay_list), GFP_KERNEL);
|
|
+ u32 *delay_list __free(kfree) = kcalloc(num_delays, sizeof(*delay_list),
|
|
+ GFP_KERNEL);
|
|
if (!delay_list)
|
|
return -ENOMEM;
|
|
|
|
@@ -1246,7 +1246,6 @@ static int find_sdca_entity_ge(struct device *dev,
|
|
struct sdca_entity *entity)
|
|
{
|
|
struct sdca_entity_ge *group = &entity->ge;
|
|
- u8 *affected_list __free(kfree) = NULL;
|
|
u8 *affected_iter;
|
|
int num_affected;
|
|
int i, j;
|
|
@@ -1265,7 +1264,8 @@ static int find_sdca_entity_ge(struct device *dev,
|
|
return -EINVAL;
|
|
}
|
|
|
|
- affected_list = kcalloc(num_affected, sizeof(*affected_list), GFP_KERNEL);
|
|
+ u8 *affected_list __free(kfree) = kcalloc(num_affected, sizeof(*affected_list),
|
|
+ GFP_KERNEL);
|
|
if (!affected_list)
|
|
return -ENOMEM;
|
|
|
|
@@ -1491,7 +1491,6 @@ static int find_sdca_entities(struct device *dev, struct sdw_slave *sdw,
|
|
struct fwnode_handle *function_node,
|
|
struct sdca_function_data *function)
|
|
{
|
|
- u32 *entity_list __free(kfree) = NULL;
|
|
struct sdca_entity *entities;
|
|
int num_entities;
|
|
int i, ret;
|
|
@@ -1513,7 +1512,8 @@ static int find_sdca_entities(struct device *dev, struct sdw_slave *sdw,
|
|
if (!entities)
|
|
return -ENOMEM;
|
|
|
|
- entity_list = kcalloc(num_entities, sizeof(*entity_list), GFP_KERNEL);
|
|
+ u32 *entity_list __free(kfree) = kcalloc(num_entities, sizeof(*entity_list),
|
|
+ GFP_KERNEL);
|
|
if (!entity_list)
|
|
return -ENOMEM;
|
|
|
|
@@ -1638,7 +1638,6 @@ static int find_sdca_entity_connection_pde(struct device *dev,
|
|
struct sdca_entity *entity)
|
|
{
|
|
struct sdca_entity_pde *power = &entity->pde;
|
|
- u32 *managed_list __free(kfree) = NULL;
|
|
struct sdca_entity **managed;
|
|
int num_managed;
|
|
int i;
|
|
@@ -1660,7 +1659,8 @@ static int find_sdca_entity_connection_pde(struct device *dev,
|
|
if (!managed)
|
|
return -ENOMEM;
|
|
|
|
- managed_list = kcalloc(num_managed, sizeof(*managed_list), GFP_KERNEL);
|
|
+ u32 *managed_list __free(kfree) = kcalloc(num_managed, sizeof(*managed_list),
|
|
+ GFP_KERNEL);
|
|
if (!managed_list)
|
|
return -ENOMEM;
|
|
|
|
@@ -1957,7 +1957,6 @@ static int find_sdca_clusters(struct device *dev,
|
|
struct fwnode_handle *function_node,
|
|
struct sdca_function_data *function)
|
|
{
|
|
- u32 *cluster_list __free(kfree) = NULL;
|
|
struct sdca_cluster *clusters;
|
|
int num_clusters;
|
|
int i, ret;
|
|
@@ -1978,7 +1977,8 @@ static int find_sdca_clusters(struct device *dev,
|
|
if (!clusters)
|
|
return -ENOMEM;
|
|
|
|
- cluster_list = kcalloc(num_clusters, sizeof(*cluster_list), GFP_KERNEL);
|
|
+ u32 *cluster_list __free(kfree) = kcalloc(num_clusters, sizeof(*cluster_list),
|
|
+ GFP_KERNEL);
|
|
if (!cluster_list)
|
|
return -ENOMEM;
|
|
|
|
@@ -2022,7 +2022,6 @@ static int find_sdca_filesets(struct device *dev, struct sdw_slave *sdw,
|
|
{
|
|
static const int mult_fileset = 3;
|
|
char fileset_name[SDCA_PROPERTY_LENGTH];
|
|
- u32 *filesets_list __free(kfree) = NULL;
|
|
struct sdca_fdl_set *sets;
|
|
int num_sets;
|
|
int i, j;
|
|
@@ -2037,7 +2036,8 @@ static int find_sdca_filesets(struct device *dev, struct sdw_slave *sdw,
|
|
return num_sets;
|
|
}
|
|
|
|
- filesets_list = kcalloc(num_sets, sizeof(u32), GFP_KERNEL);
|
|
+ u32 *filesets_list __free(kfree) = kcalloc(num_sets, sizeof(u32),
|
|
+ GFP_KERNEL);
|
|
if (!filesets_list)
|
|
return -ENOMEM;
|
|
|
|
@@ -2049,7 +2049,6 @@ static int find_sdca_filesets(struct device *dev, struct sdw_slave *sdw,
|
|
return -ENOMEM;
|
|
|
|
for (i = 0; i < num_sets; i++) {
|
|
- u32 *fileset_entries __free(kfree) = NULL;
|
|
struct sdca_fdl_set *set = &sets[i];
|
|
struct sdca_fdl_file *files;
|
|
int num_files, num_entries;
|
|
@@ -2075,7 +2074,8 @@ static int find_sdca_filesets(struct device *dev, struct sdw_slave *sdw,
|
|
if (!files)
|
|
return -ENOMEM;
|
|
|
|
- fileset_entries = kcalloc(num_entries, sizeof(u32), GFP_KERNEL);
|
|
+ u32 *fileset_entries __free(kfree) = kcalloc(num_entries, sizeof(u32),
|
|
+ GFP_KERNEL);
|
|
if (!fileset_entries)
|
|
return -ENOMEM;
|
|
|
|
--
|
|
2.43.0
|
|
|