crypto: cavium - fix leak on curr if curr->head fails to be allocated
authorColin Ian King <colin.king@canonical.com>
Fri, 17 Feb 2017 15:57:43 +0000 (15:57 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 27 Feb 2017 10:09:38 +0000 (18:09 +0800)
The exit path when curr->head cannot be allocated fails to kfree the
earlier allocated curr.  Fix this by kfree'ing it.

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_main.c

index e50872e..6ffc740 100644 (file)
@@ -242,6 +242,7 @@ static int alloc_command_queues(struct cpt_vf *cptvf,
                        if (!curr->head) {
                                dev_err(&pdev->dev, "Command Q (%d) chunk (%d) allocation failed\n",
                                        i, queue->nchunks);
+                               kfree(curr);
                                goto cmd_qfail;
                        }