Skip to contentSkip to conversation

soundwire: intel: fix memory leak with devm_kasprintf

PATCH Applied Pierre-Louis Bossart 2 participants 2 messages Jun 17, 2020 – Jun 22, 2020 SoundWire

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soundwire: intel: fix memory leak with devm_kasprintf

The dais are allocated with devm_kcalloc() but their name isn't resourced managed and never freed. Fix by also using devm_ for the dai names as well.

---
 drivers/soundwire/intel.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/soundwire/intel.c +3 -2
index 4cfdd074e310..c7422740edd4 100644
@@ -930,8 +930,9 @@ static int intel_create_dai(struct sdw_cdns *cdns,
 
 	 /* TODO: Read supported rates/formats from hardware */
 	for (i = off; i < (off + num); i++) {
-		dais[i].name = kasprintf(GFP_KERNEL, "SDW%d Pin%d",
-					 cdns->instance, i);
+		dais[i].name = devm_kasprintf(cdns->dev, GFP_KERNEL,
+					      "SDW%d Pin%d",
+					      cdns->instance, i);
 		if (!dais[i].name)
 			return -ENOMEM;
 
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw
Quoted 3 lines · Pierre-Louis Bossart

The dais are allocated with devm_kcalloc() but their name isn't resourced managed and never freed. Fix by also using devm_ for the dai names as well.

Applied, thanks

Signature · 1 line
~Vinod