arm: virt: Fix segmentation fault when specifying an unsupported CPU
commitabf3a4e5eeab9b1d4dea4149a9e77d970fe83fc5
authorShannon Zhao <shannon.zhao@linaro.org>
Fri, 20 Jan 2017 11:15:08 +0000 (20 11:15 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Fri, 20 Jan 2017 11:15:08 +0000 (20 11:15 +0000)
tree98115370edb635fb3aeb918d51d8e9fc59801485
parentd769a1da342d6af58adcaf1db2752654963a6a8b
arm: virt: Fix segmentation fault when specifying an unsupported CPU

Using -cpu cortex-a9 (or any other unsupported CPU) with the virt
board will cause QEMU to segmentation fault.  This bug was introduced
in commit 9ac4ef77, which incorrectly added a NULL terminator when
converting the VirtBoardInfo array into a simple array of strings
defining the valid CPUs. The cpuname_valid() loop already has
a termination condition based on ARRAY_SIZE, so the NULL is
spurious and causes the strcmp() to segfault if we reach it.
Delete the NULL.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Message-id: 1484619334-10488-1-git-send-email-zhaoshenglong@huawei.com
[PMM: expanded commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
hw/arm/virt.c