Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752834AbdHJC2l (ORCPT ); Wed, 9 Aug 2017 22:28:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45630 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752547AbdHJC2j (ORCPT ); Wed, 9 Aug 2017 22:28:39 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DC5A52CE92C Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=bhe@redhat.com Date: Thu, 10 Aug 2017 10:28:34 +0800 From: Baoquan He To: Pan Bian , akpm@linux-foundation.org Cc: Eric Biederman , kexec@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [V2] kexec_file: use crypto_free_shash to free memory Message-ID: <20170810022834.GA2345@x1> References: <1502278201-14562-1-git-send-email-bianpan2016@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1502278201-14562-1-git-send-email-bianpan2016@163.com> User-Agent: Mutt/1.7.0 (2016-08-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 10 Aug 2017 02:28:39 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1119 Lines: 39 On 08/09/17 at 07:30pm, Pan Bian wrote: > In function kexec_calculate_store_digests(), kfree() is used to free > memory allocated by crypto_alloc_shash(). It is better to use function > crypto_free_shash(), which frees up tfm and any resources associated with > it. And then, the refcount of the algorithm used in crypto_alloc_shash() > is also dropped. > > Signed-off-by: Pan Bian Makes sense to call the crypto alloc/free api in pairs. Acked-by: Baoquan He > --- > kernel/kexec_file.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c > index 9f48f44..94eeb38 100644 > --- a/kernel/kexec_file.c > +++ b/kernel/kexec_file.c > @@ -627,7 +627,7 @@ static int kexec_calculate_store_digests(struct kimage *image) > out_free_desc: > kfree(desc); > out_free_tfm: > - kfree(tfm); > + crypto_free_shash(tfm); > out: > return ret; > } > -- > 1.9.1 > > > > _______________________________________________ > kexec mailing list > kexec@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kexec