If ccp_dev_init() fails, kfree() the allocated ccp since it will otherwise
be leaked.
Fixes: 720419f01832 ("crypto: ccp - Introduce the AMD Secure Processor
device")
Reported-by: Cfir Cohen <[email protected]>
Signed-off-by: David Rientjes <[email protected]>
---
drivers/crypto/ccp/ccp-dev.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
--- a/drivers/crypto/ccp/ccp-dev.c
+++ b/drivers/crypto/ccp/ccp-dev.c
@@ -609,6 +609,7 @@ int ccp_dev_init(struct sp_device *sp)
e_err:
sp->ccp_data = NULL;
+ kfree(ccp);
dev_notice(dev, "ccp initialization failed\n");
On 6/23/19 2:18 PM, David Rientjes wrote:
> If ccp_dev_init() fails, kfree() the allocated ccp since it will otherwise
> be leaked.
Not needed. It's allocated with devm_kzalloc(), so it won't be leaked.
Thanks,
Tom
>
> Fixes: 720419f01832 ("crypto: ccp - Introduce the AMD Secure Processor
> device")
>
> Reported-by: Cfir Cohen <[email protected]>
> Signed-off-by: David Rientjes <[email protected]>
> ---
> drivers/crypto/ccp/ccp-dev.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
> --- a/drivers/crypto/ccp/ccp-dev.c
> +++ b/drivers/crypto/ccp/ccp-dev.c
> @@ -609,6 +609,7 @@ int ccp_dev_init(struct sp_device *sp)
>
> e_err:
> sp->ccp_data = NULL;
> + kfree(ccp);
>
> dev_notice(dev, "ccp initialization failed\n");
>
>