drm/msm: Fix incorrect struct size for memory allocation
diff mbox series

Message ID 1550786069-18328-1-git-send-email-jcrouse@codeaurora.org
State New, archived
Headers show
Series
  • drm/msm: Fix incorrect struct size for memory allocation
Related show

Commit Message

Jordan Crouse Feb. 21, 2019, 9:54 p.m. UTC
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.

Cc: stable@vger.kernel.org
Fixes: 8e54eea ("drm/msm: Add a helper function to parse clock names")
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---

 drivers/gpu/drm/msm/msm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jeffrey Hugo Feb. 21, 2019, 10:08 p.m. UTC | #1
On 2/21/2019 2:54 PM, Jordan Crouse wrote:
> 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.
> 
> Cc: stable@vger.kernel.org
> Fixes: 8e54eea ("drm/msm: Add a helper function to parse clock names")
> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
> ---
> 
>   drivers/gpu/drm/msm/msm_drv.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 906b2bb..31e1481 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -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?

Patch
diff mbox series

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 906b2bb..31e1481 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -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;