Skip to contentSkip to conversation

crypto: cavium: fix memory leak on info

PATCH In review Colin King 2 participants 2 messages Nov 15, 2017 – Nov 29, 2017

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 crypto: cavium: fix memory leak on info

From: Colin Ian King <[email protected]>

The object info is being leaked on an error return path, fix this by setting ret to -ENOMEM and exiting via the request_cleanup path that will free info.

Detected by CoverityScan, CID#1408439 ("Resource Leak")

Fixes c694b233295b ("crypto: cavium - Add the Virtual Function driver for CPT")
---
 drivers/crypto/cavium/cpt/cptvf_reqmanager.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/cavium/cpt/cptvf_reqmanager.c +2 -1
index 169e66231bcf..b0ba4331944b 100644
@@ -459,7 +459,8 @@ int process_request(struct cpt_vf *cptvf, struct cpt_request_info *req)
 	info->completion_addr = kzalloc(sizeof(union cpt_res_s), GFP_KERNEL);
 	if (unlikely(!info->completion_addr)) {
 		dev_err(&pdev->dev, "Unable to allocate memory for completion_addr\n");
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto request_cleanup;
 	}
 
 	result = (union cpt_res_s *)info->completion_addr;
Signature · 1 line
2.14.1
maintainer
#1 lore raw
Quoted 10 lines · Colin King

From: Colin Ian King <[email protected]>

The object info is being leaked on an error return path, fix this by setting ret to -ENOMEM and exiting via the request_cleanup path that will free info.

Detected by CoverityScan, CID#1408439 ("Resource Leak")

Fixes c694b233295b ("crypto: cavium - Add the Virtual Function driver for CPT")

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt