Skip to content

Commit

Permalink
crypto: cavium - fix memory leak on info
Browse files Browse the repository at this point in the history
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: c694b23 ("crypto: cavium - Add the Virtual Function driver for CPT")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Colin Ian King authored and Herbert Xu committed Nov 29, 2017
1 parent c968327 commit 87aae50
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/crypto/cavium/cpt/cptvf_reqmanager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 87aae50

Please sign in to comment.