]> git.sur5r.net Git - u-boot/commitdiff
nvme: Fix ndev->queues allocation
authorBin Meng <bmeng.cn@gmail.com>
Tue, 22 Aug 2017 15:15:08 +0000 (08:15 -0700)
committerTom Rini <trini@konsulko.com>
Mon, 28 Aug 2017 11:17:11 +0000 (07:17 -0400)
ndev->queues is a pointer to pointer, but the allocation wrongly
requests sizeof(struct nvme_queue). Fix it.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
drivers/nvme/nvme.c

index 2ac0870ae6b72dc7e71abc50a25930164d697141..5d39cab90db1658028539f67812f860de9e7ad03 100644 (file)
@@ -785,13 +785,13 @@ static int nvme_probe(struct udevice *udev)
                goto free_nvme;
        }
 
-       ndev->queues = malloc(2 * sizeof(struct nvme_queue));
+       ndev->queues = malloc(2 * sizeof(struct nvme_queue *));
        if (!ndev->queues) {
                ret = -ENOMEM;
                printf("Error: %s: Out of memory!\n", udev->name);
                goto free_nvme;
        }
-       memset(ndev->queues, 0, sizeof(2 * sizeof(struct nvme_queue)));
+       memset(ndev->queues, 0, sizeof(2 * sizeof(struct nvme_queue *)));
 
        ndev->prp_pool = malloc(MAX_PRP_POOL);
        if (!ndev->prp_pool) {