crypto: cavium - fix memory leak on info
authorColin Ian King <colin.king@canonical.com>
Wed, 15 Nov 2017 12:37:19 +0000 (12:37 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 29 Nov 2017 06:33:27 +0000 (17:33 +1100)
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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/cavium/cpt/cptvf_reqmanager.c

index 169e66231bcf15c4500507d9d88536f3cf4626a4..b0ba4331944b52b9093636e13b88b3e071ae182b 100644 (file)
@@ -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;