linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Liao Chang <liaochang1@huawei.com>,
	seanjc@google.com, tglx@linutronix.de, mingo@redhat.com,
	bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com
Cc: x86@kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, Joe Perches <joe@perches.com>
Subject: Re: [PATCH 2/2] KVM: x86: Fix a typo about the usage of kvcalloc()
Date: Thu, 3 Nov 2022 14:39:21 +0100	[thread overview]
Message-ID: <5374345c-7973-6a3c-d559-73bf4ac15079@redhat.com> (raw)
In-Reply-To: <20221103011749.139262-1-liaochang1@huawei.com>

On 11/3/22 02:17, Liao Chang wrote:
> Swap the 1st and 2nd arguments to be consistent with the usage of
> kvcalloc().
> 
> Fixes: c9b8fecddb5b ("KVM: use kvcalloc for array allocations")
> Signed-off-by: Liao Chang<liaochang1@huawei.com>
> ---
>   arch/x86/kvm/cpuid.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 7065462378e2..b33c18b142c2 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -1331,7 +1331,7 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid,
>   	if (sanity_check_entries(entries, cpuid->nent, type))
>   		return -EINVAL;
>   
> -	array.entries = kvcalloc(sizeof(struct kvm_cpuid_entry2), cpuid->nent, GFP_KERNEL);
> +	array.entries = kvcalloc(cpuid->nent, sizeof(struct kvm_cpuid_entry2), GFP_KERNEL);
>   	if (!array.entries)
>   		return -ENOMEM;
>   

It doesn't make any difference, but scripts/checkpatch.pl checks it so
let's fix the sole occurrence in KVM.

However, please send a patch to scripts/checkpatch.pl to include calloc(),
kvmalloc_array and kvcalloc() in the matched functions:

# check for alloc argument mismatch
                 if ($line =~ /\b((?:devm_)?(?:kcalloc|kmalloc_array))\s*\(\s*sizeof\b/) {
                         WARN("ALLOC_ARRAY_ARGS",
                              "$1 uses number as first arg, sizeof is generally wrong\n" . $herecurr);
                 }


Paolo


  parent reply	other threads:[~2022-11-03 13:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03  1:17 [PATCH 2/2] KVM: x86: Fix a typo about the usage of kvcalloc() Liao Chang
2022-11-03  2:37 ` Bagas Sanjaya
2022-11-03  4:18   ` liaochang (A)
2022-11-03  5:21     ` Joe Perches
2022-11-03 13:39 ` Paolo Bonzini [this message]
2022-11-04  4:06   ` liaochang (A)

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=5374345c-7973-6a3c-d559-73bf4ac15079@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=joe@perches.com \
    --cc=kvm@vger.kernel.org \
    --cc=liaochang1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@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).