diff mbox

[U-Boot,03/14] nvme: Fix ndev->queues allocation

Message ID 1503414919-30820-4-git-send-email-bmeng.cn@gmail.com
State Accepted
Commit 099c2015b02352df9c829acbdc3d8e6e683011a5
Delegated to: Tom Rini
Headers show

Commit Message

Bin Meng Aug. 22, 2017, 3:15 p.m. UTC
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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Tom Rini Aug. 29, 2017, 2:55 a.m. UTC | #1
On Tue, Aug 22, 2017 at 08:15:08AM -0700, Bin Meng wrote:

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

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index 2ac0870..5d39cab 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -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) {