Skip to contentSkip to conversation

soc: qcom: wcnss: fix leak of fw

PATCH Applied Rosen Penev 2 participants 2 messages Apr 7 – May 12

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

PATCH 1/1 soc: qcom: wcnss: fix leak of fw

The kzalloc_flex call needs to release it, not just blindly return.

Also move kfree up as it is allocated after fw.

---
 drivers/soc/qcom/wcnss_ctrl.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/soc/qcom/wcnss_ctrl.c +7 -4
index ffb31a049d4a..942e11feba65 100644
@@ -221,8 +221,10 @@ static int wcnss_download_nv(struct wcnss_ctrl *wcnss, bool *expect_cbc)
 	left = fw->size;
 
 	req = kzalloc_flex(*req, fragment, NV_FRAGMENT_SIZE);
-	if (!req)
-		return -ENOMEM;
+	if (!req) {
+		ret = -ENOMEM;
+		goto release_fw;
+	}
 
 	req->frag_size = NV_FRAGMENT_SIZE;
 	req->hdr.type = WCNSS_DOWNLOAD_NV_REQ;
@@ -243,7 +245,7 @@ static int wcnss_download_nv(struct wcnss_ctrl *wcnss, bool *expect_cbc)
 		ret = rpmsg_send(wcnss->channel, req, req->hdr.len);
 		if (ret < 0) {
 			dev_err(dev, "failed to send smd packet\n");
-			goto release_fw;
+			goto release_req;
 		}
 
 		/* Increment for next fragment */
@@ -262,9 +264,10 @@ static int wcnss_download_nv(struct wcnss_ctrl *wcnss, bool *expect_cbc)
 		ret = 0;
 	}
 
+release_req:
+	kfree(req);
 release_fw:
 	release_firmware(fw);
-	kfree(req);
 
 	return ret;
 }
Signature · 1 line
2.53.0
maintainer Applied
#1 lore raw
Quoted 5 lines · Rosen Penev

The kzalloc_flex call needs to release it, not just blindly return.

Also move kfree up as it is allocated after fw.

Applied, thanks!

[1/1] soc: qcom: wcnss: fix leak of fw

      commit: 75c9015d0d8b66ef878ac6c4b753175ada3f8aa5

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>