diff mbox

[net-next] qed: fix invalid use of sizeof in qed_alloc_qm_data()

Message ID 20170425070718.14790-1-weiyj.lk@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Wei Yongjun April 25, 2017, 7:07 a.m. UTC
From: Wei Yongjun <weiyongjun1@huawei.com>

sizeof() when applied to a pointer typed expression gives the
size of the pointer, not that of the pointed data.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/net/ethernet/qlogic/qed/qed_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mintz, Yuval April 25, 2017, 1:43 p.m. UTC | #1
> sizeof() when applied to a pointer typed expression gives the size of the
> pointer, not that of the pointed data.
> 
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Thanks!
Acked-by: Yuval Mintz <Yuval.Mintz@cavium.com>

I'd also mention that -

Fixes: b5a9ee7cf3be ("qed: Revise QM configuration")
David Miller April 25, 2017, 4 p.m. UTC | #2
From: Wei Yongjun <weiyj.lk@gmail.com>
Date: Tue, 25 Apr 2017 07:07:18 +0000

> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> sizeof() when applied to a pointer typed expression gives the
> size of the pointer, not that of the pointed data.
> 
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Applied with Yuval's Fixes: tag added.
diff mbox

Patch

diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 2498785..4fa5a1e 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -820,7 +820,7 @@  static int qed_alloc_qm_data(struct qed_hwfn *p_hwfn)
 	if (!qm_info->qm_vport_params)
 		goto alloc_err;
 
-	qm_info->qm_port_params = kzalloc(sizeof(qm_info->qm_port_params) *
+	qm_info->qm_port_params = kzalloc(sizeof(*qm_info->qm_port_params) *
 					  p_hwfn->cdev->num_ports_in_engines,
 					  GFP_KERNEL);
 	if (!qm_info->qm_port_params)