KVM Archive on lore.kernel.org
 help / color / Atom feed
From: linmiaohe <linmiaohe@huawei.com>
To: Haiwei Li <lihaiwei.kernel@gmail.com>
Cc: "pbonzini@redhat.com" <pbonzini@redhat.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] KVM: Add the check and free to avoid unknown errors.
Date: Sat, 15 Feb 2020 02:00:16 +0000
Message-ID: <fdc45fbc0b9c4c38ab539c1abf0f1e4a@huawei.com> (raw)

Hi:
Haiwei Li <lihaiwei.kernel@gmail.com> wrote:
> From: Haiwei Li <lihaiwei@tencent.com>
>
> If 'kvm_create_vm_debugfs()' fails in 'kzalloc(sizeof(*stat_data), ...)', 'kvm_destroy_vm_debugfs()' will be called by the final fput(file) in 'kvm_dev_ioctl_create_vm()'.
>
> Add the check and free to avoid unknown errors.

Add the check and free? According to the code,it seem what you mean is "add the check against free" ?
 
>
> Signed-off-by: Haiwei Li <lihaiwei@tencent.com>
>
>   	if (kvm->debugfs_stat_data) {
> -		for (i = 0; i < kvm_debugfs_num_entries; i++)
> +		for (i = 0; i < kvm_debugfs_num_entries; i++) {
> +			if (!kvm->debugfs_stat_data[i])
> +				break;
>   			kfree(kvm->debugfs_stat_data[i]);
> +		}
>   		kfree(kvm->debugfs_stat_data);
>   	}
>   }

If (!kvm->debugfs_stat_data[i]) is checked in kfree() internal. And break early seems have no different effect.
Could you please explain what unknown errors may occur? And how? Thanks.


             reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-15  2:00 linmiaohe [this message]
2020-02-15  5:33 ` Haiwei Li
  -- strict thread matches above, loose matches on Subject: below --
2020-02-14 21:02 Haiwei Li
2020-02-17 17:15 ` Paolo Bonzini

Reply instructions:

You may reply publically 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=fdc45fbc0b9c4c38ab539c1abf0f1e4a@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=kvm@vger.kernel.org \
    --cc=lihaiwei.kernel@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.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

KVM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kvm/0 kvm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kvm kvm/ https://lore.kernel.org/kvm \
		kvm@vger.kernel.org
	public-inbox-index kvm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.kvm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git