diff mbox

crypto: cavium: fix leak on curr if curr->head fails to be allocated

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

Commit Message

Colin King Feb. 17, 2017, 3:57 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

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>
---
 drivers/crypto/cavium/cpt/cptvf_main.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Herbert Xu Feb. 27, 2017, 10:37 a.m. UTC | #1
On Fri, Feb 17, 2017 at 03:57:43PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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>

Patch applied.  Thanks.
diff mbox

Patch

diff --git a/drivers/crypto/cavium/cpt/cptvf_main.c b/drivers/crypto/cavium/cpt/cptvf_main.c
index 527bdc3..3247c7f 100644
--- a/drivers/crypto/cavium/cpt/cptvf_main.c
+++ b/drivers/crypto/cavium/cpt/cptvf_main.c
@@ -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;
 			}