mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 12:40:53 +07:00
drivers/clk: convert VL struct to struct_size
There are a few manually-calculated variable-length struct allocations left, this converts them to use struct_size. Found with the following git grep command git grep -A1 'kzalloc.*sizeof[^_].*+' Signed-off-by: Stephen Kitt <steve@sk2.org> Link: https://lkml.kernel.org/r/20190927185110.29897-1-steve@sk2.org Acked-by: Gustavo A. R. Silva <gustavo@embeddedor.com> [sboyd@kernel.org: Add grep command] Signed-off-by: Stephen Boyd <sboyd@kernel.org>
This commit is contained in:
parent
54ecb8f702
commit
e620a1e061
@ -478,8 +478,7 @@ static void __init of_sam9x60_sckc_setup(struct device_node *np)
|
|||||||
if (IS_ERR(slow_osc))
|
if (IS_ERR(slow_osc))
|
||||||
goto unregister_slow_rc;
|
goto unregister_slow_rc;
|
||||||
|
|
||||||
clk_data = kzalloc(sizeof(*clk_data) + (2 * sizeof(struct clk_hw *)),
|
clk_data = kzalloc(struct_size(clk_data, hws, 2), GFP_KERNEL);
|
||||||
GFP_KERNEL);
|
|
||||||
if (!clk_data)
|
if (!clk_data)
|
||||||
goto unregister_slow_osc;
|
goto unregister_slow_osc;
|
||||||
|
|
||||||
|
@ -58,8 +58,7 @@ static void __init clk_boston_setup(struct device_node *np)
|
|||||||
cpu_div = ext_field(mmcmdiv, BOSTON_PLAT_MMCMDIV_CLK1DIV);
|
cpu_div = ext_field(mmcmdiv, BOSTON_PLAT_MMCMDIV_CLK1DIV);
|
||||||
cpu_freq = mult_frac(in_freq, mul, cpu_div);
|
cpu_freq = mult_frac(in_freq, mul, cpu_div);
|
||||||
|
|
||||||
onecell = kzalloc(sizeof(*onecell) +
|
onecell = kzalloc(struct_size(onecell, hws, BOSTON_CLK_COUNT),
|
||||||
(BOSTON_CLK_COUNT * sizeof(struct clk_hw *)),
|
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!onecell)
|
if (!onecell)
|
||||||
return;
|
return;
|
||||||
|
@ -358,8 +358,7 @@ static int __init ingenic_tcu_probe(struct device_node *np)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tcu->clocks = kzalloc(sizeof(*tcu->clocks) +
|
tcu->clocks = kzalloc(struct_size(tcu->clocks, hws, TCU_CLK_COUNT),
|
||||||
sizeof(*tcu->clocks->hws) * TCU_CLK_COUNT,
|
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!tcu->clocks) {
|
if (!tcu->clocks) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
@ -274,8 +274,8 @@ static int ap_cpu_clock_probe(struct platform_device *pdev)
|
|||||||
if (!ap_cpu_clk)
|
if (!ap_cpu_clk)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
ap_cpu_data = devm_kzalloc(dev, sizeof(*ap_cpu_data) +
|
ap_cpu_data = devm_kzalloc(dev, struct_size(ap_cpu_data, hws,
|
||||||
sizeof(struct clk_hw *) * nclusters,
|
nclusters),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!ap_cpu_data)
|
if (!ap_cpu_data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -235,8 +235,8 @@ static int cp110_syscon_common_probe(struct platform_device *pdev,
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
cp110_clk_data = devm_kzalloc(dev, sizeof(*cp110_clk_data) +
|
cp110_clk_data = devm_kzalloc(dev, struct_size(cp110_clk_data, hws,
|
||||||
sizeof(struct clk_hw *) * CP110_CLK_NUM,
|
CP110_CLK_NUM),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!cp110_clk_data)
|
if (!cp110_clk_data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -60,8 +60,7 @@ struct samsung_clk_provider *__init samsung_clk_init(struct device_node *np,
|
|||||||
struct samsung_clk_provider *ctx;
|
struct samsung_clk_provider *ctx;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ctx = kzalloc(sizeof(struct samsung_clk_provider) +
|
ctx = kzalloc(struct_size(ctx, clk_data.hws, nr_clks), GFP_KERNEL);
|
||||||
sizeof(*ctx->clk_data.hws) * nr_clks, GFP_KERNEL);
|
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
panic("could not allocate clock provider context.\n");
|
panic("could not allocate clock provider context.\n");
|
||||||
|
|
||||||
|
@ -64,8 +64,7 @@ static int uniphier_clk_probe(struct platform_device *pdev)
|
|||||||
for (p = data; p->name; p++)
|
for (p = data; p->name; p++)
|
||||||
clk_num = max(clk_num, p->idx + 1);
|
clk_num = max(clk_num, p->idx + 1);
|
||||||
|
|
||||||
hw_data = devm_kzalloc(dev,
|
hw_data = devm_kzalloc(dev, struct_size(hw_data, hws, clk_num),
|
||||||
sizeof(*hw_data) + clk_num * sizeof(struct clk_hw *),
|
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!hw_data)
|
if (!hw_data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
Loading…
Reference in New Issue
Block a user