mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Jesper Juhl <jj@chaosbits.net>
Cc: linux-kernel@vger.kernel.org, Peter Oruba <peter.oruba@amd.com>,
	Andreas Herrmann <andreas.herrmann3@amd.com>,
	amd64-microcode@amd64.org
Subject: Re: [PATCH] AMD Microcode: Prefer vzalloc() over calls to vmalloc()+memset()
Date: Sun, 31 Oct 2010 11:08:33 +0100	[thread overview]
Message-ID: <20101031100833.GA18633@liondog.tnic> (raw)
In-Reply-To: <alpine.LNX.2.00.1010302118160.1572@swampdragon.chaosbits.net>

On Sat, Oct 30, 2010 at 09:23:14PM +0200, Jesper Juhl wrote:
> We don't have to do memset() ourselves after vmalloc() when we have 
> vzalloc(), so change that in 
> arch/x86/kernel/microcode_amd.c::get_next_ucode().
> 
> Please CC me on replies.
> 
> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
> compile tested only.
> 
>  microcode_amd.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
> index e1af7c0..d46e805 100644
> --- a/arch/x86/kernel/microcode_amd.c
> +++ b/arch/x86/kernel/microcode_amd.c
> @@ -183,9 +183,8 @@ get_next_ucode(const u8 *buf, unsigned int size, unsigned int *mc_size)
>  		return NULL;
>  	}
>  
> -	mc = vmalloc(UCODE_MAX_SIZE);
> +	mc = vzalloc(UCODE_MAX_SIZE);
>  	if (mc) {
> -		memset(mc, 0, UCODE_MAX_SIZE);
>  		if (get_ucode_data(mc, buf + UCODE_CONTAINER_SECTION_HDR,
>  				   total_size)) {
>  			vfree(mc);

Good.

Better yet, you can go a step further and remove one indentation block:

--
	mc = vzalloc(UCODE_MAX_SIZE);
	if (!mc)
		goto out;

	if (get_ucode_data(mc, ...
	...

out:
	return mc;

}
--
making the code even fit in 80 chars width and thus more readable.

Thanks.

-- 
Regards/Gruss,
    Boris.

  reply	other threads:[~2010-10-31 10:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-30 19:23 Jesper Juhl
2010-10-31 10:08 ` Borislav Petkov [this message]
2010-11-01 19:23   ` Jesper Juhl
2010-11-01 21:27     ` Borislav Petkov
2010-11-01 21:44       ` [PATCH v2] " Jesper Juhl
2010-11-02 17:51         ` Borislav Petkov

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=20101031100833.GA18633@liondog.tnic \
    --to=bp@alien8.de \
    --cc=amd64-microcode@amd64.org \
    --cc=andreas.herrmann3@amd.com \
    --cc=jj@chaosbits.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.oruba@amd.com \
    /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

all inboxes | Powered by JetHome®