Skip to contentSkip to conversation

clk: Annotate struct clk_hw_onecell_data with __counted_by

PATCH Applied Kees Cook 3 participants 3 messages Aug 17, 2023 – Aug 22, 2023

Subsystems (15)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 clk: Annotate struct clk_hw_onecell_data with __counted_by

Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions).

As found with Coccinelle[1], add __counted_by for struct clk_hw_onecell_data. Additionally, since the element count member must be set before accessing the annotated flexible array member, move its initialization earlier.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc Michael Turquette <[email protected]>
Cc Stephen Boyd <[email protected]>
Cc Joel Stanley <[email protected]>
Cc Andrew Jeffery <[email protected]>
Cc Taichi Sugaya <[email protected]>
Cc Takao Orito <[email protected]>
Cc Qin Jian <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc Gregory Clement <[email protected]>
Cc Sebastian Hesselbarth <[email protected]>
Cc Andy Gross <[email protected]>
Cc Bjorn Andersson <[email protected]>
Cc Konrad Dybcio <[email protected]>
Cc Sergio Paracuellos <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc AngeloGioacchino Del Regno <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Chen-Yu Tsai <[email protected]>
Cc Jernej Skrabec <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Samuel Holland <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Kishon Vijay Abraham I <[email protected]>
Cc linux-clk at vger.kernel.org
Cc linux-arm-kernel at lists.infradead.org
Cc linux-aspeed at lists.ozlabs.org
Cc linux-arm-msm at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc dri-devel at lists.freedesktop.org
Cc linux-sunxi at lists.linux.dev
Cc linux-phy at lists.infradead.org
---
 drivers/clk/clk-aspeed.c                    | 3 +--
 drivers/clk/clk-ast2600.c                   | 2 +-
 drivers/clk/clk-gemini.c                    | 2 +-
 drivers/clk/clk-milbeaut.c                  | 3 +--
 drivers/clk/clk-sp7021.c                    | 3 +--
 drivers/clk/mvebu/cp110-system-controller.c | 2 +-
 drivers/clk/qcom/clk-cpu-8996.c             | 2 +-
 drivers/clk/ralink/clk-mt7621.c             | 3 +--
 drivers/gpu/drm/sun4i/sun8i_tcon_top.c      | 3 +--
 drivers/phy/qualcomm/phy-qcom-edp.c         | 2 +-
 include/linux/clk-provider.h                | 2 +-
 11 files changed, 11 insertions(+), 16 deletions(-)
drivers/clk/clk-aspeed.c +1 -2
index 284710adaef5..ff84191d0fe8 100644
@@ -701,6 +701,7 @@ static void __init aspeed_cc_init(struct device_node *np)
 				  GFP_KERNEL);
 	if (!aspeed_clk_data)
 		return;
+	aspeed_clk_data->num = ASPEED_NUM_CLKS;
 
 	/*
 	 * This way all clocks fetched before the platform device probes,
@@ -732,8 +733,6 @@ static void __init aspeed_cc_init(struct device_node *np)
 		aspeed_ast2500_cc(map);
 	else
 		pr_err("unknown platform, failed to add clocks\n");
-
-	aspeed_clk_data->num = ASPEED_NUM_CLKS;
 	ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, aspeed_clk_data);
 	if (ret)
 		pr_err("failed to add DT provider: %d\n", ret);
drivers/clk/clk-ast2600.c +1 -1
index f9e27f95a967..909c3137c428 100644
@@ -839,6 +839,7 @@ static void __init aspeed_g6_cc_init(struct device_node *np)
 				      ASPEED_G6_NUM_CLKS), GFP_KERNEL);
 	if (!aspeed_g6_clk_data)
 		return;
+	aspeed_g6_clk_data->num = ASPEED_G6_NUM_CLKS;
 
 	/*
 	 * This way all clocks fetched before the platform device probes,
@@ -860,7 +861,6 @@ static void __init aspeed_g6_cc_init(struct device_node *np)
 	}
 
 	aspeed_g6_cc(map);
-	aspeed_g6_clk_data->num = ASPEED_G6_NUM_CLKS;
 	ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, aspeed_g6_clk_data);
 	if (ret)
 		pr_err("failed to add DT provider: %d\n", ret);
drivers/clk/clk-gemini.c +1 -1
index a23fa6d47ef1..2572d15aadd0 100644
@@ -404,6 +404,7 @@ static void __init gemini_cc_init(struct device_node *np)
 				  GFP_KERNEL);
 	if (!gemini_clk_data)
 		return;
+	gemini_clk_data->num = GEMINI_NUM_CLKS;
 
 	/*
 	 * This way all clock fetched before the platform device probes,
@@ -457,7 +458,6 @@ static void __init gemini_cc_init(struct device_node *np)
 	gemini_clk_data->hws[GEMINI_CLK_APB] = hw;
 
 	/* Register the clocks to be accessed by the device tree */
-	gemini_clk_data->num = GEMINI_NUM_CLKS;
 	of_clk_add_hw_provider(np, of_clk_hw_onecell_get, gemini_clk_data);
 }
 CLK_OF_DECLARE_DRIVER(gemini_cc, "cortina,gemini-syscon", gemini_cc_init);
drivers/clk/clk-milbeaut.c +1 -2
index 050fd4fb588f..18c20aff45f7 100644
@@ -618,6 +618,7 @@ static void __init m10v_cc_init(struct device_node *np)
 
 	if (!m10v_clk_data)
 		return;
+	m10v_clk_data->num = M10V_NUM_CLKS;
 
 	base = of_iomap(np, 0);
 	if (!base) {
@@ -654,8 +655,6 @@ static void __init m10v_cc_init(struct device_node *np)
 					base + CLKSEL(1), 0, 3, 0, rclk_table,
 					&m10v_crglock, NULL);
 	m10v_clk_data->hws[M10V_RCLK_ID] = hw;
-
-	m10v_clk_data->num = M10V_NUM_CLKS;
 	of_clk_add_hw_provider(np, of_clk_hw_onecell_get, m10v_clk_data);
 }
 CLK_OF_DECLARE_DRIVER(m10v_cc, "socionext,milbeaut-m10v-ccu", m10v_cc_init);
drivers/clk/clk-sp7021.c +1 -2
index 11d22043ddd7..01d3c4c7b0b2 100644
@@ -621,6 +621,7 @@ static int sp7021_clk_probe(struct platform_device *pdev)
 				GFP_KERNEL);
 	if (!clk_data)
 		return -ENOMEM;
+	clk_data->num = CLK_MAX;
 
 	hws = clk_data->hws;
 	pd_ext.index = 0;
@@ -688,8 +689,6 @@ static int sp7021_clk_probe(struct platform_device *pdev)
 			return PTR_ERR(hws[i]);
 	}
 
-	clk_data->num = CLK_MAX;
-
 	return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
 }
 
drivers/clk/mvebu/cp110-system-controller.c +1 -1
index 84c8900542e4..03c59bf22106 100644
@@ -240,9 +240,9 @@ static int cp110_syscon_common_probe(struct platform_device *pdev,
 				      GFP_KERNEL);
 	if (!cp110_clk_data)
 		return -ENOMEM;
+	cp110_clk_data->num = CP110_CLK_NUM;
 
 	cp110_clks = cp110_clk_data->hws;
-	cp110_clk_data->num = CP110_CLK_NUM;
 
 	/* Register the PLL0 which is the root of the hw tree */
 	pll0_name = ap_cp_unique_name(dev, syscon_node, "pll0");
drivers/clk/qcom/clk-cpu-8996.c +1 -1
index 592c7c3cdeb7..72689448a653 100644
@@ -590,6 +590,7 @@ static int qcom_cpu_clk_msm8996_driver_probe(struct platform_device *pdev)
 	data = devm_kzalloc(dev, struct_size(data, hws, 2), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
+	data->num = 2;
 
 	base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(base))
@@ -605,7 +606,6 @@ static int qcom_cpu_clk_msm8996_driver_probe(struct platform_device *pdev)
 
 	data->hws[0] = &pwrcl_pmux.clkr.hw;
 	data->hws[1] = &perfcl_pmux.clkr.hw;
-	data->num = 2;
 
 	return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, data);
 }
drivers/clk/ralink/clk-mt7621.c +1 -2
index d95a33293b0a..92d14350c4b3 100644
@@ -521,6 +521,7 @@ static int mt7621_clk_probe(struct platform_device *pdev)
 				GFP_KERNEL);
 	if (!clk_data)
 		return -ENOMEM;
+	clk_data->num = count;
 
 	for (i = 0; i < ARRAY_SIZE(mt7621_clks_base); i++)
 		clk_data->hws[i] = mt7621_clk_early[i];
@@ -537,8 +538,6 @@ static int mt7621_clk_probe(struct platform_device *pdev)
 		goto unreg_clk_fixed;
 	}
 
-	clk_data->num = count;
-
 	ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
 	if (ret) {
 		dev_err(dev, "Couldn't add clk hw provider\n");
drivers/gpu/drm/sun4i/sun8i_tcon_top.c +1 -2
index 6f076cf4b403..a1ca3916f42b 100644
@@ -141,6 +141,7 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
 				GFP_KERNEL);
 	if (!clk_data)
 		return -ENOMEM;
+	clk_data->num = CLK_NUM;
 	tcon_top->clk_data = clk_data;
 
 	spin_lock_init(&tcon_top->reg_lock);
@@ -213,8 +214,6 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
 			goto err_unregister_gates;
 		}
 
-	clk_data->num = CLK_NUM;
-
 	ret = of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get,
 				     clk_data);
 	if (ret)
drivers/phy/qualcomm/phy-qcom-edp.c +1 -1
index e0e722b9be31..8e5078304646 100644
@@ -744,6 +744,7 @@ static int qcom_edp_clks_register(struct qcom_edp *edp, struct device_node *np)
 	data = devm_kzalloc(edp->dev, struct_size(data, hws, 2), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
+	data->num = 2;
 
 	snprintf(name, sizeof(name), "%s::link_clk", dev_name(edp->dev));
 	init.ops = &qcom_edp_dp_link_clk_ops;
@@ -763,7 +764,6 @@ static int qcom_edp_clks_register(struct qcom_edp *edp, struct device_node *np)
 
 	data->hws[0] = &edp->dp_link_hw;
 	data->hws[1] = &edp->dp_pixel_hw;
-	data->num = 2;
 
 	return devm_of_clk_add_hw_provider(edp->dev, of_clk_hw_onecell_get, data);
 }
include/linux/clk-provider.h +1 -1
index 0f0cd01906b4..ec32ec58c59f 100644
@@ -1379,7 +1379,7 @@ struct clk_onecell_data {
 
 struct clk_hw_onecell_data {
 	unsigned int num;
-	struct clk_hw *hws[];
+	struct clk_hw *hws[] __counted_by(num);
 };
 
 #define CLK_OF_DECLARE(name, compat, fn) \
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 37 lines · Kees Cook

Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions).

As found with Coccinelle[1], add __counted_by for struct clk_hw_onecell_data. Additionally, since the element count member must be set before accessing the annotated flexible array member, move its initialization earlier.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc Michael Turquette <[email protected]>
Cc Stephen Boyd <[email protected]>
Cc Joel Stanley <[email protected]>
Cc Andrew Jeffery <[email protected]>
Cc Taichi Sugaya <[email protected]>
Cc Takao Orito <[email protected]>
Cc Qin Jian <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc Gregory Clement <[email protected]>
Cc Sebastian Hesselbarth <[email protected]>
Cc Andy Gross <[email protected]>
Cc Bjorn Andersson <[email protected]>
Cc Konrad Dybcio <[email protected]>
Cc Sergio Paracuellos <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc AngeloGioacchino Del Regno <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Chen-Yu Tsai <[email protected]>
Cc Jernej Skrabec <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Samuel Holland <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Kishon Vijay Abraham I <[email protected]>
Quoted 8 lines

Thanks
--
Gustavo

Quoted 227 lines
---
  drivers/clk/clk-aspeed.c                    | 3 +--
  drivers/clk/clk-ast2600.c                   | 2 +-
  drivers/clk/clk-gemini.c                    | 2 +-
  drivers/clk/clk-milbeaut.c                  | 3 +--
  drivers/clk/clk-sp7021.c                    | 3 +--
  drivers/clk/mvebu/cp110-system-controller.c | 2 +-
  drivers/clk/qcom/clk-cpu-8996.c             | 2 +-
  drivers/clk/ralink/clk-mt7621.c             | 3 +--
  drivers/gpu/drm/sun4i/sun8i_tcon_top.c      | 3 +--
  drivers/phy/qualcomm/phy-qcom-edp.c         | 2 +-
  include/linux/clk-provider.h                | 2 +-
  11 files changed, 11 insertions(+), 16 deletions(-)
drivers/clk/clk-aspeed.c +1 -2
index 284710adaef5..ff84191d0fe8 100644
@@ -701,6 +701,7 @@ static void __init aspeed_cc_init(struct device_node *np)
  				  GFP_KERNEL);
  	if (!aspeed_clk_data)
  		return;
+	aspeed_clk_data->num = ASPEED_NUM_CLKS;
 
  	/*
  	 * This way all clocks fetched before the platform device probes,
@@ -732,8 +733,6 @@ static void __init aspeed_cc_init(struct device_node *np)
  		aspeed_ast2500_cc(map);
  	else
  		pr_err("unknown platform, failed to add clocks\n");
-
-	aspeed_clk_data->num = ASPEED_NUM_CLKS;
  	ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, aspeed_clk_data);
  	if (ret)
  		pr_err("failed to add DT provider: %d\n", ret);
drivers/clk/clk-ast2600.c +1 -1
index f9e27f95a967..909c3137c428 100644
@@ -839,6 +839,7 @@ static void __init aspeed_g6_cc_init(struct device_node *np)
  				      ASPEED_G6_NUM_CLKS), GFP_KERNEL);
  	if (!aspeed_g6_clk_data)
  		return;
+	aspeed_g6_clk_data->num = ASPEED_G6_NUM_CLKS;
 
  	/*
  	 * This way all clocks fetched before the platform device probes,
@@ -860,7 +861,6 @@ static void __init aspeed_g6_cc_init(struct device_node *np)
  	}
 
  	aspeed_g6_cc(map);
-	aspeed_g6_clk_data->num = ASPEED_G6_NUM_CLKS;
  	ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, aspeed_g6_clk_data);
  	if (ret)
  		pr_err("failed to add DT provider: %d\n", ret);
drivers/clk/clk-gemini.c +1 -1
index a23fa6d47ef1..2572d15aadd0 100644
@@ -404,6 +404,7 @@ static void __init gemini_cc_init(struct device_node *np)
  				  GFP_KERNEL);
  	if (!gemini_clk_data)
  		return;
+	gemini_clk_data->num = GEMINI_NUM_CLKS;
 
  	/*
  	 * This way all clock fetched before the platform device probes,
@@ -457,7 +458,6 @@ static void __init gemini_cc_init(struct device_node *np)
  	gemini_clk_data->hws[GEMINI_CLK_APB] = hw;
 
  	/* Register the clocks to be accessed by the device tree */
-	gemini_clk_data->num = GEMINI_NUM_CLKS;
  	of_clk_add_hw_provider(np, of_clk_hw_onecell_get, gemini_clk_data);
  }
  CLK_OF_DECLARE_DRIVER(gemini_cc, "cortina,gemini-syscon", gemini_cc_init);
drivers/clk/clk-milbeaut.c +1 -2
index 050fd4fb588f..18c20aff45f7 100644
@@ -618,6 +618,7 @@ static void __init m10v_cc_init(struct device_node *np)
 
  	if (!m10v_clk_data)
  		return;
+	m10v_clk_data->num = M10V_NUM_CLKS;
 
  	base = of_iomap(np, 0);
  	if (!base) {
@@ -654,8 +655,6 @@ static void __init m10v_cc_init(struct device_node *np)
  					base + CLKSEL(1), 0, 3, 0, rclk_table,
  					&m10v_crglock, NULL);
  	m10v_clk_data->hws[M10V_RCLK_ID] = hw;
-
-	m10v_clk_data->num = M10V_NUM_CLKS;
  	of_clk_add_hw_provider(np, of_clk_hw_onecell_get, m10v_clk_data);
  }
  CLK_OF_DECLARE_DRIVER(m10v_cc, "socionext,milbeaut-m10v-ccu", m10v_cc_init);
drivers/clk/clk-sp7021.c +1 -2
index 11d22043ddd7..01d3c4c7b0b2 100644
@@ -621,6 +621,7 @@ static int sp7021_clk_probe(struct platform_device *pdev)
  				GFP_KERNEL);
  	if (!clk_data)
  		return -ENOMEM;
+	clk_data->num = CLK_MAX;
 
  	hws = clk_data->hws;
  	pd_ext.index = 0;
@@ -688,8 +689,6 @@ static int sp7021_clk_probe(struct platform_device *pdev)
  			return PTR_ERR(hws[i]);
  	}
 
-	clk_data->num = CLK_MAX;
-
  	return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
  }
 
drivers/clk/mvebu/cp110-system-controller.c +1 -1
index 84c8900542e4..03c59bf22106 100644
@@ -240,9 +240,9 @@ static int cp110_syscon_common_probe(struct platform_device *pdev,
  				      GFP_KERNEL);
  	if (!cp110_clk_data)
  		return -ENOMEM;
+	cp110_clk_data->num = CP110_CLK_NUM;
 
  	cp110_clks = cp110_clk_data->hws;
-	cp110_clk_data->num = CP110_CLK_NUM;
 
  	/* Register the PLL0 which is the root of the hw tree */
  	pll0_name = ap_cp_unique_name(dev, syscon_node, "pll0");
drivers/clk/qcom/clk-cpu-8996.c +1 -1
index 592c7c3cdeb7..72689448a653 100644
@@ -590,6 +590,7 @@ static int qcom_cpu_clk_msm8996_driver_probe(struct platform_device *pdev)
  	data = devm_kzalloc(dev, struct_size(data, hws, 2), GFP_KERNEL);
  	if (!data)
  		return -ENOMEM;
+	data->num = 2;
 
  	base = devm_platform_ioremap_resource(pdev, 0);
  	if (IS_ERR(base))
@@ -605,7 +606,6 @@ static int qcom_cpu_clk_msm8996_driver_probe(struct platform_device *pdev)
 
  	data->hws[0] = &pwrcl_pmux.clkr.hw;
  	data->hws[1] = &perfcl_pmux.clkr.hw;
-	data->num = 2;
 
  	return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, data);
  }
drivers/clk/ralink/clk-mt7621.c +1 -2
index d95a33293b0a..92d14350c4b3 100644
@@ -521,6 +521,7 @@ static int mt7621_clk_probe(struct platform_device *pdev)
  				GFP_KERNEL);
  	if (!clk_data)
  		return -ENOMEM;
+	clk_data->num = count;
 
  	for (i = 0; i < ARRAY_SIZE(mt7621_clks_base); i++)
  		clk_data->hws[i] = mt7621_clk_early[i];
@@ -537,8 +538,6 @@ static int mt7621_clk_probe(struct platform_device *pdev)
  		goto unreg_clk_fixed;
  	}
 
-	clk_data->num = count;
-
  	ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
  	if (ret) {
  		dev_err(dev, "Couldn't add clk hw provider\n");
drivers/gpu/drm/sun4i/sun8i_tcon_top.c +1 -2
index 6f076cf4b403..a1ca3916f42b 100644
@@ -141,6 +141,7 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
  				GFP_KERNEL);
  	if (!clk_data)
  		return -ENOMEM;
+	clk_data->num = CLK_NUM;
  	tcon_top->clk_data = clk_data;
 
  	spin_lock_init(&tcon_top->reg_lock);
@@ -213,8 +214,6 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
  			goto err_unregister_gates;
  		}
 
-	clk_data->num = CLK_NUM;
-
  	ret = of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get,
  				     clk_data);
  	if (ret)
drivers/phy/qualcomm/phy-qcom-edp.c +1 -1
index e0e722b9be31..8e5078304646 100644
@@ -744,6 +744,7 @@ static int qcom_edp_clks_register(struct qcom_edp *edp, struct device_node *np)
  	data = devm_kzalloc(edp->dev, struct_size(data, hws, 2), GFP_KERNEL);
  	if (!data)
  		return -ENOMEM;
+	data->num = 2;
 
  	snprintf(name, sizeof(name), "%s::link_clk", dev_name(edp->dev));
  	init.ops = &qcom_edp_dp_link_clk_ops;
@@ -763,7 +764,6 @@ static int qcom_edp_clks_register(struct qcom_edp *edp, struct device_node *np)
 
  	data->hws[0] = &edp->dp_link_hw;
  	data->hws[1] = &edp->dp_pixel_hw;
-	data->num = 2;
 
  	return devm_of_clk_add_hw_provider(edp->dev, of_clk_hw_onecell_get, data);
  }
include/linux/clk-provider.h +1 -1
index 0f0cd01906b4..ec32ec58c59f 100644
@@ -1379,7 +1379,7 @@ struct clk_onecell_data {
 
  struct clk_hw_onecell_data {
  	unsigned int num;
-	struct clk_hw *hws[];
+	struct clk_hw *hws[] __counted_by(num);
  };
 
  #define CLK_OF_DECLARE(name, compat, fn) \
Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
maintainer Applied
#2 lore raw
In reply to Kees Cook

Quoting Kees Cook (2023-08-17 13:30:22)

Quoted 45 lines

Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions).

As found with Coccinelle[1], add __counted_by for struct clk_hw_onecell_data. Additionally, since the element count member must be set before accessing the annotated flexible array member, move its initialization earlier.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc Michael Turquette <[email protected]>
Cc Stephen Boyd <[email protected]>
Cc Joel Stanley <[email protected]>
Cc Andrew Jeffery <[email protected]>
Cc Taichi Sugaya <[email protected]>
Cc Takao Orito <[email protected]>
Cc Qin Jian <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc Gregory Clement <[email protected]>
Cc Sebastian Hesselbarth <[email protected]>
Cc Andy Gross <[email protected]>
Cc Bjorn Andersson <[email protected]>
Cc Konrad Dybcio <[email protected]>
Cc Sergio Paracuellos <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc AngeloGioacchino Del Regno <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Chen-Yu Tsai <[email protected]>
Cc Jernej Skrabec <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Samuel Holland <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Kishon Vijay Abraham I <[email protected]>
Cc linux-clk at vger.kernel.org
Cc linux-arm-kernel at lists.infradead.org
Cc linux-aspeed at lists.ozlabs.org
Cc linux-arm-msm at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc dri-devel at lists.freedesktop.org
Cc linux-sunxi at lists.linux.dev
Cc linux-phy at lists.infradead.org
Quoted 1 line

---

Applied to clk-next