Skip to contentSkip to conversation

ASoC: Intel: sst: Fix firmware resource leak in sst_request_fw()

PATCH New [email protected] 1 participant 1 message Apr 3

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Intel: sst: Fix firmware resource leak in sst_request_fw()

From: Aravind Anilraj <[email protected]>

The sst_request_fw() function calls request_firmware() but does not release the firmware on any return path, resulting in a resource leak.

Ensure release_firmware() is called after the firmware has been processed to properly free the allocated resources.

This issue was identified by smatch.

---
 sound/soc/intel/atom/sst/sst_loader.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/intel/atom/sst/sst_loader.c +4 -2
index a043443d2887..cba7f26cb0fd 100644
@@ -350,12 +350,14 @@ static int sst_request_fw(struct intel_sst_drv *sst)
 	}
 	if (fw == NULL) {
 		dev_err(sst->dev, "fw is returning as null\n");
-		return -EINVAL;
+		retval = -EINVAL;
+		goto out;
 	}
 	mutex_lock(&sst->sst_lock);
 	retval = sst_cache_and_parse_fw(sst, fw);
 	mutex_unlock(&sst->sst_lock);
-
+out:
+	release_firmware(fw);
 	return retval;
 }
 
Signature · 1 line
2.47.3