Skip to content

Commit 49ef649

Browse files
pchelkin91bebarino
authored andcommitted
clk: tegra: do not overallocate memory for bpmp clocks
struct tegra_bpmp::clocks is a pointer to a dynamically allocated array of pointers to 'struct tegra_bpmp_clk'. But the size of the allocated area is calculated like it is an array containing actual 'struct tegra_bpmp_clk' objects - it's not true, there are just pointers. Found by Linux Verification Center (linuxtesting.org) with Svace static analysis tool. Fixes: 2db12b1 ("clk: tegra: Register clocks from root to leaf") Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 41bba99 commit 49ef649

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/clk/tegra/clk-bpmp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ static int tegra_bpmp_register_clocks(struct tegra_bpmp *bpmp,
635635

636636
bpmp->num_clocks = count;
637637

638-
bpmp->clocks = devm_kcalloc(bpmp->dev, count, sizeof(struct tegra_bpmp_clk), GFP_KERNEL);
638+
bpmp->clocks = devm_kcalloc(bpmp->dev, count, sizeof(*bpmp->clocks), GFP_KERNEL);
639639
if (!bpmp->clocks)
640640
return -ENOMEM;
641641

0 commit comments

Comments
 (0)