Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp352778pxj; Tue, 18 May 2021 05:02:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfCTPKyYmzKTBqo89OpHTl+fGm8EHrCt3myotux4iA74FcPr3CxvLIm4v0OXVbdls5Py32 X-Received: by 2002:a17:907:33d4:: with SMTP id zk20mr5674719ejb.330.1621339359013; Tue, 18 May 2021 05:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621339359; cv=none; d=google.com; s=arc-20160816; b=CfoydgaM7a2L+X48XeDzEEd7AgrKsaqFt0GgukEcjouYBWEBA53/oMnF4xnX+BC5DH Eniy7QVpHjLW/+AR3qEh9luMbgEpzU3HCYEFfCkxiAb2WmlL7YmFMSwm/LkHPrxn6zKQ 3lniWteE9nluPHQhfYXrdTv1jUgCLvjFoyJsvgpJ+hlQjK4dnYJQaFCaNqlD4qnyqkSd YAsBdm2HFnUdSiYFHV/MuVA3PF/2Ib7sxdj1Zm5mIadJL1XwkvlXdhV3H1Dg0Uy7LIde bVHPAtOArVRVSZmjZW5AsMiBOdA8o0sY1C7UHTFCyQnOF0idgKwDKTqtvitBAvG1sgwX AhGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LwSsDDIbNUKx7JvSGACpiScr377zEKcnpE+57fm/RYM=; b=Bq+CM8WtvzBIcAlVIOmUFZZPATT064S+nxxX2kiE6OKlkjUo8eF52uaTwvZu/mE6/B NAaJrk05E4E4pHr1jn1bcLioNRUaL4eYTRsut6GCa6QGDKBS2VMJ86S2eFHa+Kd9Uht0 3ElX2Z8hFNP4xAeeM8PdZQynBzYPWdFZkOJDENNAGimZVQ7d2lu8PW8SQe533qBQIAGP M34i+8zzN3f4LMFli/fLRamXya5pxG7XT9u0OlU25YZu/IBk1XAKJCi9/oGz+6wm+wyF HxvAXsCYycrywa8fXa0gRI5vcLWSeJbiCp1ddsCS7nP01ZExdSrcP7wZwikCuqjp2nDh UC6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qYmlvm3f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v7si20649965edd.153.2021.05.18.05.01.54; Tue, 18 May 2021 05:02:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qYmlvm3f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241637AbhEQPZc (ORCPT + 99 others); Mon, 17 May 2021 11:25:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:34450 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242430AbhEQPLe (ORCPT ); Mon, 17 May 2021 11:11:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A0DE3617ED; Mon, 17 May 2021 14:31:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261862; bh=40hQnL67yDel9pKz/Y1QEu7i9cfHv98AEBna5R7P3s8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qYmlvm3f3u4tc0xO9Vb6hbWqe9ZUVRPrPdGMq0gW18rTRBPSymbq3MROSetjBTDOR qB98JlhoabdZfH9xx/tqlonTFxgcMn7aZdaMp8Nzo5reKDUSx20kU4C8qNDp6Dhv+g 31XEQd3pzrXXXPbYzXxLE9mK0bnoF8ZfitEGqGRQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Brijesh Singh , Tom Lendacky , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.10 077/289] crypto: ccp: Free SEV device if SEV init fails Date: Mon, 17 May 2021 16:00:02 +0200 Message-Id: <20210517140307.787144288@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson [ Upstream commit b61a9071dc72a3c709192c0c00ab87c2b3de1d94 ] 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 Message-Id: <20210406224952.4177376-2-seanjc@google.com> Reviewed-by: Brijesh Singh Acked-by: Tom Lendacky Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- drivers/crypto/ccp/sev-dev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 5b82ba7acc7c..21caed429cc5 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -989,7 +989,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); @@ -1004,6 +1004,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; -- 2.30.2