QEMU-Arm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Shannon Zhao <zhaoshenglong@huawei.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm <qemu-arm@nongnu.org>,
	QEMU Developers <qemu-devel@nongnu.org>,
	wu.wubin@huawei.com
Subject: Re: [Qemu-arm] [PATCH] arm: virt: Fix the segmentation fault when specifying an unsupported CPU
Date: Tue, 17 Jan 2017 09:21:26 +0800	[thread overview]
Message-ID: <587D7196.8080209@huawei.com> (raw)
In-Reply-To: <CAFEAcA_pKX-v6q2uE-5+mWXYyEfooYCUFu4kVEL1N_DS5yjA2A@mail.gmail.com>



On 2017/1/17 1:27, Peter Maydell wrote:
> On 15 January 2017 at 10:51, Shannon Zhao <zhaoshenglong@huawei.com> wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> For example, using -cpu generic will cause qemu segmentation fault.
>>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  hw/arm/virt.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
>> index 7a03f84..4b301c2 100644
>> --- a/hw/arm/virt.c
>> +++ b/hw/arm/virt.c
>> @@ -175,7 +175,7 @@ static bool cpuname_valid(const char *cpu)
>>      int i;
>>
>>      for (i = 0; i < ARRAY_SIZE(valid_cpus); i++) {
>> -        if (strcmp(cpu, valid_cpus[i]) == 0) {
>> +        if (valid_cpus[i] != NULL && strcmp(cpu, valid_cpus[i]) == 0) {
>>              return true;
>>          }
>>      }
> 
> A better fix is to just remove the NULL entry from the
> valid_cpus[] array. We already have one "stop when we
> run out of entries" condition (the ARRAY_SIZE check),
> we don't need two...
> 
Right. Will send the update one.

Thanks,
-- 
Shannon


      reply	other threads:[~2017-01-17  1:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-15 10:51 [Qemu-arm] [PATCH] arm: virt: Fix the segmentation fault when specifying an unsupported CPU Shannon Zhao
2017-01-16 17:27 ` Peter Maydell
2017-01-17  1:21   ` Shannon Zhao [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=587D7196.8080209@huawei.com \
    --to=zhaoshenglong@huawei.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wu.wubin@huawei.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