Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3026311pxj; Mon, 17 May 2021 15:55:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1vP9OyRPcvSiJrwjhcZ7uLRZhVCtcp8Tn/1tK+xo9iFQgjP/8ds0VpNrU4isDhOhrC6F8 X-Received: by 2002:a05:6e02:1985:: with SMTP id g5mr1644941ilf.103.1621292119681; Mon, 17 May 2021 15:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621292119; cv=none; d=google.com; s=arc-20160816; b=QfYxAt0ko4+0V/muLSjZCDJKO/21Sd9UsBN82YYdg8cEDdPNlONHhltuaJrbdVBut1 9uJgH7z3OHVJ0/U++57Tkt0pZFYo/fRyNn7B5i2/fPstH5G9jM7+WIxNL58kuMnfoYHh 4cgEyOmUNb2pqAYpD3pw1ufo22464HAS06xCZZK6LhfQkz4iKfOQdsjpcX7DoOzcHbar 86xzxNneBln02MmsvMhfqXFbFEEuTjhAIppkFTTZ7kvZBQ0vvFS16+/5p35NvphOlWro HlrRExhG9UyLZWKFurlAmvYyFsqILP4XekPvsKbFEKAQTPMPooGip8HKxstT0w/GyEVs diaA== 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=hjLZD7Bup2t4kGDHnO+Kgsv0yHGDKo6CUvCrGGu+sRo=; b=P5PJevi65On6NcSj3YxRG8TAv7bSpxVuJZTCJKMbVBj9QhmmnrECvvoN671ST9Ad4p fKKy8K8OcyvPc6LIwFsHk2oE/eSvz07po3Ru2uNaNE/SjdBmwayUNPHUy8vgLrn4vZB1 8zN9OSv9JjinJ7V9SrvjPUPTGM3XSiDUj+wiEl01XmGGwV92xSyi5fvhAquAmfyxbu+F 6prdTISLL6WAVxY06RgPnRFIU5S6B+LFPF3g9+YOw1JmdQ1PK+9UDRNZtjQDTjeyLncW y6mN9WNz/VfNMGpwhmsdeawEV0coL/CozyyIshpEN/h+h+bkbRUM9xXP1pvYZYoljxCM 565g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iVxGDI7e; 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 t19si19713463iog.66.2021.05.17.15.55.07; Mon, 17 May 2021 15:55:19 -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=iVxGDI7e; 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 S238700AbhEQOSN (ORCPT + 99 others); Mon, 17 May 2021 10:18:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:49310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238441AbhEQOPs (ORCPT ); Mon, 17 May 2021 10:15:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D1982613DB; Mon, 17 May 2021 14:09:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260568; bh=dLPephp8Pl5+nlW5eNBPLQ6Uvj5TFwSjFuD7qq3814o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iVxGDI7ezd4aZLPBcjPaC6qMyLt+uLoXBRM8pMbtBUytLXKINCHWJpBQDGdkKDI/Z 7u6zWpep8sJRsCHVc/Vhq8GBBgveB/go1A7Gnn8xYPBjlKctbZGmoTYnOwGMgtzsam fT3ALAI9tnVf1fwmn9s4gCbfImqWlrVzQV5gG5i8= 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.12 106/363] crypto: ccp: Free SEV device if SEV init fails Date: Mon, 17 May 2021 15:59:32 +0200 Message-Id: <20210517140306.201663991@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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 8fd43c1acac1..3e0d1d6922ba 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -990,7 +990,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); @@ -1005,6 +1005,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