Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752430AbdHILao (ORCPT ); Wed, 9 Aug 2017 07:30:44 -0400 Received: from m12-13.163.com ([220.181.12.13]:50366 "EHLO m12-13.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752260AbdHILan (ORCPT ); Wed, 9 Aug 2017 07:30:43 -0400 From: Pan Bian To: Eric Biederman Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Pan Bian Subject: [V2] kexec_file: use crypto_free_shash to free memory Date: Wed, 9 Aug 2017 19:30:01 +0800 Message-Id: <1502278201-14562-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: DcCowAD3pGFD8opZI8ZRDg--.45726S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrKr45ArW7XF15tF1fJw1DZFb_yoW3ZFg_Ga y8Gw1FvF10va1kXa1UJ3yYvFy0gw13GF9Y9r1fXFW7WrW5JwsIvwn7uw4fGFn8G397AF95 Gr9aqFsxJw429jkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0E4EtUUUUU== X-Originating-IP: [1.202.67.190] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiVAYvclUMBQqYPAAAs9 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 771 Lines: 27 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 --- 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