DM: virtio-gpio: fix array overflow issue

explicitly initialize the cmd_cap string array.

Tracked-On: #3001
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Liu Yuan 2019-04-19 09:24:28 +08:00 committed by wenlingz
parent fb9bd2a19a
commit 90343a48fa

View File

@ -1571,13 +1571,14 @@ print_virtio_gpio_info(struct virtio_gpio_request *req,
struct virtio_gpio_response *rsp, bool in) struct virtio_gpio_response *rsp, bool in)
{ {
const char *item; const char *item;
const char *const cmd_map[] = { const char *const cmd_map[GPIO_REQ_MAX + 1] = {
"GPIO_REQ_SET_VALUE", "GPIO_REQ_SET_VALUE",
"GPIO_REQ_GET_VALUE", "GPIO_REQ_GET_VALUE",
"GPIO_REQ_INPUT_DIRECTION", "GPIO_REQ_INPUT_DIRECTION",
"GPIO_REQ_OUTPUT_DIRECTION", "GPIO_REQ_OUTPUT_DIRECTION",
"GPIO_REQ_GET_DIRECTION", "GPIO_REQ_GET_DIRECTION",
"GPIO_REQ_SET_CONFIG", "GPIO_REQ_SET_CONFIG",
"GPIO_REQ_MAX",
}; };
if (req->cmd == GPIO_REQ_SET_VALUE || req->cmd == GPIO_REQ_GET_VALUE) if (req->cmd == GPIO_REQ_SET_VALUE || req->cmd == GPIO_REQ_GET_VALUE)