Skip to contentSkip to conversation

soundwire: Fix error return code in sdw_compute_port_params

PATCH In review Qinglang Miao 2 participants 2 messages Nov 25, 2020 – Nov 30, 2020 SoundWire

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soundwire: Fix error return code in sdw_compute_port_params

Fix to return the error code -EINVAL in sdw_compute_port_params instead of 0.

Fixes 9026118f20e2 ("soundwire: Add generic bandwidth allocation algorithm")
---
 drivers/soundwire/generic_bandwidth_allocation.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/soundwire/generic_bandwidth_allocation.c +3 -1
index 0bdef38c9..ad857ac62 100644
@@ -283,8 +283,10 @@ static int sdw_compute_port_params(struct sdw_bus *bus)
 	if (ret < 0)
 		return ret;
 
-	if (group.count == 0)
+	if (group.count == 0) {
+		ret = -EINVAL;
 		goto out;
+	}
 
 	params = kcalloc(group.count, sizeof(*params), GFP_KERNEL);
 	if (!params) {
Signature · 1 line
2.23.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Qinglang Miao

Fix to return the error code -EINVAL in sdw_compute_port_params instead of 0.

Fixes 9026118f20e2 ("soundwire: Add generic bandwidth allocation algorithm")

Thanks for the patch.
The test covers a very unlikely error scenario but nevertheless not a zero probability so the suggested fix makes sense to me.

Quoted 21 lines
---
  drivers/soundwire/generic_bandwidth_allocation.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/soundwire/generic_bandwidth_allocation.c +3 -1
index 0bdef38c9..ad857ac62 100644
@@ -283,8 +283,10 @@ static int sdw_compute_port_params(struct sdw_bus *bus)
  	if (ret < 0)
  		return ret;
 
-	if (group.count == 0)
+	if (group.count == 0) {
+		ret = -EINVAL;
  		goto out;
+	}
 
  	params = kcalloc(group.count, sizeof(*params), GFP_KERNEL);
  	if (!params) {