linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: Pan Bian <bianpan2016@163.com>, akpm@linux-foundation.org
Cc: Eric Biederman <ebiederm@xmission.com>,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [V2] kexec_file: use crypto_free_shash to free memory
Date: Thu, 10 Aug 2017 10:28:34 +0800	[thread overview]
Message-ID: <20170810022834.GA2345@x1> (raw)
In-Reply-To: <1502278201-14562-1-git-send-email-bianpan2016@163.com>

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 <bianpan2016@163.com>

Makes sense to call the crypto alloc/free api in pairs.

Acked-by: Baoquan He <bhe@redhat.com>

> ---
>  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

      reply	other threads:[~2017-08-10  2:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-09 11:30 [V2] kexec_file: use crypto_free_shash to free memory Pan Bian
2017-08-10  2:28 ` Baoquan He [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170810022834.GA2345@x1 \
    --to=bhe@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=bianpan2016@163.com \
    --cc=ebiederm@xmission.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).