Skip to contentSkip to conversation

phy: qcom-qmp: fix invalid use of sizeof in qcom_qmp_phy_vreg_init()

PATCH In review Wei Yongjun 2 participants 2 messages Apr 25, 2017 Generic PHY framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 phy: qcom-qmp: fix invalid use of sizeof in qcom_qmp_phy_vreg_init()

From: Wei Yongjun <[email protected]>

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

---
 drivers/phy/phy-qcom-qmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/phy-qcom-qmp.c +1 -1
index 727e23b..7d6085f 100644
@@ -844,7 +844,7 @@ static int qcom_qmp_phy_vreg_init(struct device *dev)
 	int num = qmp->cfg->num_vregs;
 	int i;
 
-	qmp->vregs = devm_kcalloc(dev, num, sizeof(qmp->vregs), GFP_KERNEL);
+	qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL);
 	if (!qmp->vregs)
 		return -ENOMEM;
#1 lore raw

Hi,

Quoted 7 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

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

---

Apparently Kbuild had caught this and sent a similar patch. But I missed that.

Thank you for the patch. I have requested Kishon to pull in the patch from Kbuild along with your patch [1] fixing the return value for of_iomap.

[1] https://lkml.org/lkml/2017/4/24/1080

Best Regards
Vivek

Quoted 16 lines
  drivers/phy/phy-qcom-qmp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/phy-qcom-qmp.c +1 -1
index 727e23b..7d6085f 100644
@@ -844,7 +844,7 @@ static int qcom_qmp_phy_vreg_init(struct device *dev)
  	int num = qmp->cfg->num_vregs;
  	int i;
 
-	qmp->vregs = devm_kcalloc(dev, num, sizeof(qmp->vregs), GFP_KERNEL);
+	qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL);
  	if (!qmp->vregs)
  		return -ENOMEM;
 
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project