diff options
author | Sean Christopherson <seanjc@google.com> | 2021-04-06 15:49:45 -0700 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-04-21 12:20:05 -0400 |
commit | b61a9071dc72a3c709192c0c00ab87c2b3de1d94 (patch) | |
tree | cb691be65bdee6bcd2e46eb14c1799f73f927e17 /drivers/crypto/ccp/sev-dev.c | |
parent | 6a443def87d2698f4fa2d7b57e7f4e5f0f61671a (diff) | |
download | linux-b61a9071dc72a3c709192c0c00ab87c2b3de1d94.tar.gz linux-b61a9071dc72a3c709192c0c00ab87c2b3de1d94.tar.bz2 linux-b61a9071dc72a3c709192c0c00ab87c2b3de1d94.zip |
crypto: ccp: Free SEV device if SEV init fails
Free the SEV device if later initialization fails. The memory isn't
technically leaked as it's tracked in the top-level device's devres
list, but unless the top-level device is removed, the memory won't be
freed and is effectively leaked.
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210406224952.4177376-2-seanjc@google.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'drivers/crypto/ccp/sev-dev.c')
-rw-r--r-- | drivers/crypto/ccp/sev-dev.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 4172a1afa0db..b9afaea2a3d3 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -988,7 +988,7 @@ int sev_dev_init(struct psp_device *psp) if (!sev->vdata) { ret = -ENODEV; dev_err(dev, "sev: missing driver data\n"); - goto e_err; + goto e_sev; } psp_set_sev_irq_handler(psp, sev_irq_handler, sev); @@ -1003,6 +1003,8 @@ int sev_dev_init(struct psp_device *psp) e_irq: psp_clear_sev_irq_handler(psp); +e_sev: + devm_kfree(dev, sev); e_err: psp->sev_data = NULL; |