diff mbox

crypto: cavium: fix memory leak on info

Message ID 20171115123719.12667-1-colin.king@canonical.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show

Commit Message

Colin King Nov. 15, 2017, 12:37 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

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")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/crypto/cavium/cpt/cptvf_reqmanager.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Herbert Xu Nov. 29, 2017, 6:37 a.m. UTC | #1
On Wed, Nov 15, 2017 at 12:37:19PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Patch applied.  Thanks.
diff mbox

Patch

diff --git a/drivers/crypto/cavium/cpt/cptvf_reqmanager.c b/drivers/crypto/cavium/cpt/cptvf_reqmanager.c
index 169e66231bcf..b0ba4331944b 100644
--- a/drivers/crypto/cavium/cpt/cptvf_reqmanager.c
+++ b/drivers/crypto/cavium/cpt/cptvf_reqmanager.c
@@ -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;