drm/msm/gpu: Set number of clocks to 0 if the list allocation fails
authorJordan Crouse <jcrouse@codeaurora.org>
Mon, 22 Jan 2018 18:10:45 +0000 (11:10 -0700)
committerRob Clark <robdclark@gmail.com>
Tue, 20 Feb 2018 15:41:22 +0000 (10:41 -0500)
If we fail to allocate gpu->grp_clks reset the number of available
clocks to zero to avoid referencing the missing array later.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
drivers/gpu/drm/msm/msm_gpu.c

index 8078e4d..1c09acf 100644 (file)
@@ -682,8 +682,10 @@ static int get_clocks(struct platform_device *pdev, struct msm_gpu *gpu)
 
        gpu->grp_clks = devm_kcalloc(dev, sizeof(struct clk *), gpu->nr_clocks,
                GFP_KERNEL);
-       if (!gpu->grp_clks)
+       if (!gpu->grp_clks) {
+               gpu->nr_clocks = 0;
                return -ENOMEM;
+       }
 
        of_property_for_each_string(dev->of_node, "clock-names", prop, name) {
                gpu->grp_clks[i] = get_clock(dev, name);