Message ID | 20220516132527.328190-25-maxime@cerno.tech (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | clk: More clock rate fixes and tests | expand |
Quoting Maxime Ripard (2022-05-16 06:25:23) > Unlike __clk_get_name(), clk_hw_get_name() doesn't test wether passed > clk_hw pointer is NULL or not and dereferences it directly. This can > then lead to NULL pointer dereference. Why do you have a NULL clk_hw pointer? Is there some caller that is simplified with this patch?
Hi, On Wed, Jun 29, 2022 at 02:13:49AM -0700, Stephen Boyd wrote: > Quoting Maxime Ripard (2022-05-16 06:25:23) > > Unlike __clk_get_name(), clk_hw_get_name() doesn't test wether passed > > clk_hw pointer is NULL or not and dereferences it directly. This can > > then lead to NULL pointer dereference. > > Why do you have a NULL clk_hw pointer? Is there some caller that is > simplified with this patch? I encountered it while debugging the clock tree and assumed it would be a good idea, but I don't another reason. I'll drop it Maxime
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index d953ca61ea38..364e6baa3d1c 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -262,7 +262,7 @@ EXPORT_SYMBOL_GPL(__clk_get_name); const char *clk_hw_get_name(const struct clk_hw *hw) { - return hw->core->name; + return !hw ? NULL : hw->core->name; } EXPORT_SYMBOL_GPL(clk_hw_get_name);