]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
clk: zynqmp: Add a check for NULL pointer
authorShubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Wed, 18 May 2022 05:53:14 +0000 (11:23 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 22:52:44 +0000 (14:52 -0800)
[ Upstream commit 6ab9810cfe6c8f3d8b8750c827d7870abd3751b9 ]

Add a NULL pointer check as clk_hw_get_parent can return NULL.

Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Link: https://lore.kernel.org/r/20220518055314.2486-1-shubhrajyoti.datta@xilinx.com
Acked-by: Michal Simek <michal.simek@amd.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Stable-dep-of: 1fe15be1fb61 ("drivers: clk: zynqmp: update divider round rate logic")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/clk/zynqmp/divider.c

index 9e535d3e1c0c31c4efb089a77650a400cacc46ca..47a199346ddfc5896d03dfd2e06a70913b7b9f3d 100644 (file)
@@ -120,10 +120,13 @@ static void zynqmp_get_divider2_val(struct clk_hw *hw,
        long error = LONG_MAX;
        unsigned long div1_prate;
        struct clk_hw *div1_parent_hw;
+       struct zynqmp_clk_divider *pdivider;
        struct clk_hw *div2_parent_hw = clk_hw_get_parent(hw);
-       struct zynqmp_clk_divider *pdivider =
-                               to_zynqmp_clk_divider(div2_parent_hw);
 
+       if (!div2_parent_hw)
+               return;
+
+       pdivider = to_zynqmp_clk_divider(div2_parent_hw);
        if (!pdivider)
                return;