Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp273544yba; Mon, 20 May 2019 08:29:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxB7tlwc3McPoVMXOas/sJNhxiIvU5oTLRGumkL6ZpHfKXMGbUOoxg/qAqjvhXpjLsScxnB X-Received: by 2002:a17:902:363:: with SMTP id 90mr77225200pld.131.1558366143454; Mon, 20 May 2019 08:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558366143; cv=none; d=google.com; s=arc-20160816; b=AVrBrQuDqf+MJNemLw0N3nQ9RZW1n7+vwugu9aLz6btC66A4Nnf/cZpUZMRjab5SJs FTl9Yq5XJ4RxEwNpbPIp2ogiheNd9qDXBk2Yv6tA24tsnDTg8/3NnNPML7Y8UCHyKHGG Aeas6GmuPiwt3V4aOPPoSMLAFW8T3UA9WmNwcSXv5hX+Qamy1T9hsfABot8ckfgqHy48 d0OjCaF//xf3iThTlUoOjbm3SAdnz62Ka+6A3mO5qrxEVFD3ZsqYNauom2uPzBM0DWAg d7JXed0NPL3yxlxpDy3Wo1dzoUcGlMrFEbSloqOliZb5Aw8Szvs/AY9g6doEKgl1ZmIB +meQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TEOjFFbIAKtWDVj7b5kOGp66OjQtTgLzbcPkVCXl414=; b=xu4tq4Vc4A+dxU+ZFH8E0QZbWpJt/iIdbQ5HJLf1BBtaY24qeHh3ksXG6ioRubUiUe h9e947d90kpKIDS1t5A4CdmO+Wp7RwmYv24pLgqWHCfkiKvJcahtbi88TlRLGqC9/0xx S/zbR7waC9BTma1ZszX8TUSLrjToOQlMuaxP5RU1HTr3q++3LiZwddzQhB8fpNixOvov sdFuBRjSgDJXnLXeo39C4jpUx4WbwoqmCDwmB76b8fQleQ5VCLc3FiqffBOJ6Kg6dTPe SAarutNwcDf39RZMMFecKQEnfVjEk4bmuOcFiZ0p/otiYG+3cn1fZH5Rsy0kG+RN1eUx FIQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=auzmw+dp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si17827912pgb.30.2019.05.20.08.28.48; Mon, 20 May 2019 08:29:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=auzmw+dp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388613AbfETMXa (ORCPT + 99 others); Mon, 20 May 2019 08:23:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:37960 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388023AbfETMX3 (ORCPT ); Mon, 20 May 2019 08:23:29 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9365B20675; Mon, 20 May 2019 12:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355009; bh=Vc76SIEwx46ODrXQqltdqyN2/mHnKSGbQiibyzx/1hQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=auzmw+dpH+8DZGb3Sh0ZSb5o1JdWQe9lIB8YznJUcGcMzJYgrBszwKCq0jvKXQxsZ 3BzY2SQrmY6oXkSIzOEZthXnw2pbcBoVP+bWofMbLfFqVGjFepCzAYYp2vU1bKsw4H CSMRSlCe0M7TVvkMKd82rMgWDMa1aA3fqb5oxYZU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gilad Ben-Yossef , Herbert Xu Subject: [PATCH 4.19 045/105] crypto: ccree - fix mem leak on error path Date: Mon, 20 May 2019 14:13:51 +0200 Message-Id: <20190520115250.133283526@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115247.060821231@linuxfoundation.org> References: <20190520115247.060821231@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gilad Ben-Yossef commit d574b707c873d6ef1a2a155f8cfcfecd821e9a2e upstream. Fix a memory leak on the error path of IV generation code. Signed-off-by: Gilad Ben-Yossef Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccree/cc_ivgen.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) --- a/drivers/crypto/ccree/cc_ivgen.c +++ b/drivers/crypto/ccree/cc_ivgen.c @@ -154,9 +154,6 @@ void cc_ivgen_fini(struct cc_drvdata *dr } ivgen_ctx->pool = NULL_SRAM_ADDR; - - /* release "this" context */ - kfree(ivgen_ctx); } /*! @@ -174,10 +171,12 @@ int cc_ivgen_init(struct cc_drvdata *drv int rc; /* Allocate "this" context */ - ivgen_ctx = kzalloc(sizeof(*ivgen_ctx), GFP_KERNEL); + ivgen_ctx = devm_kzalloc(device, sizeof(*ivgen_ctx), GFP_KERNEL); if (!ivgen_ctx) return -ENOMEM; + drvdata->ivgen_handle = ivgen_ctx; + /* Allocate pool's header for initial enc. key/IV */ ivgen_ctx->pool_meta = dma_alloc_coherent(device, CC_IVPOOL_META_SIZE, &ivgen_ctx->pool_meta_dma, @@ -196,8 +195,6 @@ int cc_ivgen_init(struct cc_drvdata *drv goto out; } - drvdata->ivgen_handle = ivgen_ctx; - return cc_init_iv_sram(drvdata); out: