mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 04:12:04 -04:00
clk: avoid returning local variable pointers during clock registration
Several clock drivers initialize the clk_hw init element to a local variable before calling [devm_]clk_hw_register() on it. This style is fine. However, the init pointer value becomes invalid as soon as the registration function returns. Clear the init pointer to avoid the possibility of accessing an invalid memory address after registration completes. Change-Id: I3ae72c2c7ebc30e443c7034d072591827f4342aa Signed-off-by: David Collins <collinsd@codeaurora.org>
This commit is contained in:
parent
c1adb1b037
commit
e087a19247
7 changed files with 7 additions and 1 deletions
|
|
@ -510,6 +510,7 @@ static struct clk_hw *_register_divider(struct device *dev, const char *name,
|
|||
/* register the clock */
|
||||
hw = &div->hw;
|
||||
ret = clk_hw_register(dev, hw);
|
||||
hw->init = NULL;
|
||||
if (ret) {
|
||||
kfree(div);
|
||||
hw = ERR_PTR(ret);
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ __clk_hw_register_fixed_factor(struct device *dev, struct device_node *np,
|
|||
ret = clk_hw_register(dev, hw);
|
||||
else
|
||||
ret = of_clk_hw_register(np, hw);
|
||||
hw->init = NULL;
|
||||
if (ret) {
|
||||
kfree(fix);
|
||||
hw = ERR_PTR(ret);
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ struct clk_hw *clk_hw_register_fixed_rate_with_accuracy(struct device *dev,
|
|||
/* register the clock */
|
||||
hw = &fixed->hw;
|
||||
ret = clk_hw_register(dev, hw);
|
||||
hw->init = NULL;
|
||||
if (ret) {
|
||||
kfree(fixed);
|
||||
hw = ERR_PTR(ret);
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ struct clk_hw *clk_hw_register_fractional_divider(struct device *dev,
|
|||
|
||||
hw = &fd->hw;
|
||||
ret = clk_hw_register(dev, hw);
|
||||
hw->init = NULL;
|
||||
if (ret) {
|
||||
kfree(fd);
|
||||
hw = ERR_PTR(ret);
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ struct clk_hw *clk_hw_register_gate(struct device *dev, const char *name,
|
|||
|
||||
hw = &gate->hw;
|
||||
ret = clk_hw_register(dev, hw);
|
||||
hw->init = NULL;
|
||||
if (ret) {
|
||||
kfree(gate);
|
||||
hw = ERR_PTR(ret);
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ static struct clk_hw *clk_register_gpio(struct device *dev, const char *name,
|
|||
err = devm_clk_hw_register(dev, hw);
|
||||
else
|
||||
err = clk_hw_register(NULL, hw);
|
||||
|
||||
hw->init = NULL;
|
||||
if (!err)
|
||||
return hw;
|
||||
|
||||
|
|
|
|||
|
|
@ -190,6 +190,7 @@ struct clk_hw *clk_hw_register_mux_table(struct device *dev, const char *name,
|
|||
|
||||
hw = &mux->hw;
|
||||
ret = clk_hw_register(dev, hw);
|
||||
hw->init = NULL;
|
||||
if (ret) {
|
||||
kfree(mux);
|
||||
hw = ERR_PTR(ret);
|
||||
|
|
|
|||
Loading…
Reference in a new issue