All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-arm] [PATCH] arm: virt: Fix the segmentation fault when specifying an unsupported CPU
@ 2017-01-15 10:51 ` Shannon Zhao
  0 siblings, 0 replies; 6+ messages in thread
From: Shannon Zhao @ 2017-01-15 10:51 UTC (permalink / raw)
  To: qemu-arm, peter.maydell; +Cc: qemu-devel, wu.wubin, zhaoshenglong

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;
         }
     }
-- 
2.0.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH] arm: virt: Fix the segmentation fault when specifying an unsupported CPU
@ 2017-01-15 10:51 ` Shannon Zhao
  0 siblings, 0 replies; 6+ messages in thread
From: Shannon Zhao @ 2017-01-15 10:51 UTC (permalink / raw)
  To: qemu-arm, peter.maydell; +Cc: qemu-devel, zhaoshenglong, wu.wubin

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;
         }
     }
-- 
2.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-arm] [PATCH] arm: virt: Fix the segmentation fault when specifying an unsupported CPU
  2017-01-15 10:51 ` [Qemu-devel] " Shannon Zhao
@ 2017-01-16 17:27   ` Peter Maydell
  -1 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2017-01-16 17:27 UTC (permalink / raw)
  To: Shannon Zhao; +Cc: qemu-arm, QEMU Developers, wu.wubin

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

thanks
-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] arm: virt: Fix the segmentation fault when specifying an unsupported CPU
@ 2017-01-16 17:27   ` Peter Maydell
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2017-01-16 17:27 UTC (permalink / raw)
  To: Shannon Zhao; +Cc: qemu-arm, QEMU Developers, wu.wubin

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

thanks
-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-arm] [PATCH] arm: virt: Fix the segmentation fault when specifying an unsupported CPU
  2017-01-16 17:27   ` [Qemu-devel] " Peter Maydell
@ 2017-01-17  1:21     ` Shannon Zhao
  -1 siblings, 0 replies; 6+ messages in thread
From: Shannon Zhao @ 2017-01-17  1:21 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-arm, QEMU Developers, wu.wubin



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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] arm: virt: Fix the segmentation fault when specifying an unsupported CPU
@ 2017-01-17  1:21     ` Shannon Zhao
  0 siblings, 0 replies; 6+ messages in thread
From: Shannon Zhao @ 2017-01-17  1:21 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-arm, QEMU Developers, wu.wubin



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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-01-17  1:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-15 10:51 [Qemu-arm] [PATCH] arm: virt: Fix the segmentation fault when specifying an unsupported CPU Shannon Zhao
2017-01-15 10:51 ` [Qemu-devel] " Shannon Zhao
2017-01-16 17:27 ` [Qemu-arm] " Peter Maydell
2017-01-16 17:27   ` [Qemu-devel] " Peter Maydell
2017-01-17  1:21   ` [Qemu-arm] " Shannon Zhao
2017-01-17  1:21     ` [Qemu-devel] " Shannon Zhao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.