[v2,1/8] crypto: ccp: Free SEV device if SEV init fails
diff mbox series

Message ID 20210406224952.4177376-2-seanjc@google.com
State New, archived
Headers show
  • ccp: KVM: SVM: Use stack for SEV command buffers
Related show

Commit Message

Sean Christopherson April 6, 2021, 10:49 p.m. UTC
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>
 drivers/crypto/ccp/sev-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff mbox series

diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index cb9b4c4e371e..ba240d33d26e 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -987,7 +987,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);
@@ -1002,6 +1002,8 @@  int sev_dev_init(struct psp_device *psp)
+	devm_kfree(dev, sev);
 	psp->sev_data = NULL;