Skip to contentSkip to conversation

drm/msm: Fix incorrect struct size for memory allocation

PATCH In review Jordan Crouse 2 participants 2 messages Feb 21, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/msm: Fix incorrect struct size for memory allocation

The allocation for the clock bulk data does a classic sizeof(pointer) instead of sizeof(struct) so the array ends up incorrectly sized for the clock data.

Fixes 8e54eea ("drm/msm: Add a helper function to parse clock names")

---

 drivers/gpu/drm/msm/msm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_drv.c +1 -1
index 906b2bb..31e1481 100644
@@ -96,7 +96,7 @@ int msm_clk_bulk_get(struct device *dev, struct clk_bulk_data **bulk)
 	if (count < 1)
 		return 0;
 
-	local = devm_kcalloc(dev, sizeof(struct clk_bulk_data *),
+	local = devm_kcalloc(dev, sizeof(struct clk_bulk_data),
 		count, GFP_KERNEL);
 	if (!local)
 		return -ENOMEM;
Signature · 1 line
2.7.4
#1 lore raw
Quoted 18 lines · Jordan Crouse

The allocation for the clock bulk data does a classic sizeof(pointer) instead of sizeof(struct) so the array ends up incorrectly sized for the clock data.

Fixes 8e54eea ("drm/msm: Add a helper function to parse clock names")

---

  drivers/gpu/drm/msm/msm_drv.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_drv.c +0 -0
index 906b2bb..31e1481 100644

drivers/gpu/drm/msm/msm_drv.c int msm_clk_bulk_get(struct device *dev, struct clk_bulk_data **bulk) · line 102

Quoted 8 lines
drivers/gpu/drm/msm/msm_drv.c +1 -1
@@ -96,7 +96,7 @@ int msm_clk_bulk_get(struct device *dev, struct clk_bulk_data **bulk)
  	if (count < 1)
  		return 0;
 
-	local = devm_kcalloc(dev, sizeof(struct clk_bulk_data *),
+	local = devm_kcalloc(dev, sizeof(struct clk_bulk_data),
  		count, GFP_KERNEL);
  	if (!local)
  		return -ENOMEM;

Isn't msm_clk_bulk_get a duplication of devm_clk_bulk_get_all() ? Surely it would be better to just use that instead?

Signature · 4 lines
Jeffrey Hugo
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.