Skip to content

Commit f376c43

Browse files
nathanchancebebarino
authored andcommitted
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: b19f009 ("clk: bcm2835: Migrate to clk_hw based registration and OF APIs") Link: ClangBuiltLinux#1028 Signed-off-by: Nathan Chancellor <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 8f3d9f3 commit f376c43

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/clk/bcm/clk-bcm2835.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,13 +1448,13 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
14481448
return &clock->hw;
14491449
}
14501450

1451-
static struct clk *bcm2835_register_gate(struct bcm2835_cprman *cprman,
1451+
static struct clk_hw *bcm2835_register_gate(struct bcm2835_cprman *cprman,
14521452
const struct bcm2835_gate_data *data)
14531453
{
1454-
return clk_register_gate(cprman->dev, data->name, data->parent,
1455-
CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
1456-
cprman->regs + data->ctl_reg,
1457-
CM_GATE_BIT, 0, &cprman->regs_lock);
1454+
return clk_hw_register_gate(cprman->dev, data->name, data->parent,
1455+
CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
1456+
cprman->regs + data->ctl_reg,
1457+
CM_GATE_BIT, 0, &cprman->regs_lock);
14581458
}
14591459

14601460
typedef struct clk_hw *(*bcm2835_clk_register)(struct bcm2835_cprman *cprman,

0 commit comments

Comments
 (0)