Skip to content

Commit 763d218

Browse files
yliu80wenlingz
authored andcommitted
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>
1 parent f3f870b commit 763d218

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

devicemodel/hw/pci/virtio/virtio_gpio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,13 +1571,14 @@ print_virtio_gpio_info(struct virtio_gpio_request *req,
15711571
struct virtio_gpio_response *rsp, bool in)
15721572
{
15731573
const char *item;
1574-
const char *const cmd_map[] = {
1574+
const char *const cmd_map[GPIO_REQ_MAX + 1] = {
15751575
"GPIO_REQ_SET_VALUE",
15761576
"GPIO_REQ_GET_VALUE",
15771577
"GPIO_REQ_INPUT_DIRECTION",
15781578
"GPIO_REQ_OUTPUT_DIRECTION",
15791579
"GPIO_REQ_GET_DIRECTION",
15801580
"GPIO_REQ_SET_CONFIG",
1581+
"GPIO_REQ_MAX",
15811582
};
15821583

15831584
if (req->cmd == GPIO_REQ_SET_VALUE || req->cmd == GPIO_REQ_GET_VALUE)

0 commit comments

Comments
 (0)