Commit f376c43b authored by Nathan Chancellor's avatar Nathan Chancellor Committed by Stephen Boyd

clk: bcm2835: Fix return type of bcm2835_register_gate

bcm2835_register_gate is used as a callback for the clk_register member
of bcm2835_clk_desc, which expects a struct clk_hw * return type but
bcm2835_register_gate returns a struct clk *.

This discrepancy is hidden by the fact that bcm2835_register_gate is
cast to the typedef bcm2835_clk_register by the _REGISTER macro. This
turns out to be a control flow integrity violation, which is how this
was noticed.

Change the return type of bcm2835_register_gate to be struct clk_hw *
and use clk_hw_register_gate to do so. This should be a non-functional
change as clk_register_gate calls clk_hw_register_gate anyways but this
is needed to avoid issues with further changes.

Fixes: b19f009d ("clk: bcm2835: Migrate to clk_hw based registration and OF APIs")
Link: https://github.com/ClangBuiltLinux/linux/issues/1028Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
Link: https://lkml.kernel.org/r/20200516080806.1459784-1-natechancellor@gmail.comSigned-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent 8f3d9f35
...@@ -1448,13 +1448,13 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman, ...@@ -1448,13 +1448,13 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
return &clock->hw; return &clock->hw;
} }
static struct clk *bcm2835_register_gate(struct bcm2835_cprman *cprman, static struct clk_hw *bcm2835_register_gate(struct bcm2835_cprman *cprman,
const struct bcm2835_gate_data *data) const struct bcm2835_gate_data *data)
{ {
return clk_register_gate(cprman->dev, data->name, data->parent, return clk_hw_register_gate(cprman->dev, data->name, data->parent,
CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE, CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
cprman->regs + data->ctl_reg, cprman->regs + data->ctl_reg,
CM_GATE_BIT, 0, &cprman->regs_lock); CM_GATE_BIT, 0, &cprman->regs_lock);
} }
typedef struct clk_hw *(*bcm2835_clk_register)(struct bcm2835_cprman *cprman, typedef struct clk_hw *(*bcm2835_clk_register)(struct bcm2835_cprman *cprman,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment