Skip to content

Commit 1096f9f

Browse files
keesbroonie
authored andcommitted
regulator: da9063: Annotate struct da9063_regulators 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 da9063_regulators. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Support Opensource <[email protected]> Cc: Liam Girdwood <[email protected]> Cc: Mark Brown <[email protected]> Signed-off-by: Kees Cook <[email protected]> Reviewed-by: "Gustavo A. R. Silva" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 907f2a4 commit 1096f9f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/regulator/da9063-regulator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ struct da9063_regulator {
158158
struct da9063_regulators {
159159
unsigned int n_regulators;
160160
/* Array size to be defined during init. Keep at end. */
161-
struct da9063_regulator regulator[];
161+
struct da9063_regulator regulator[] __counted_by(n_regulators);
162162
};
163163

164164
/* BUCK modes for DA9063 */

0 commit comments

Comments
 (0)