summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorThorsten Blum <thorsten.blum@linux.dev>2025-06-10 13:40:59 +0300
committerKees Cook <kees@kernel.org>2025-06-19 00:20:32 +0300
commit4bfbc2691de8c869339090e851703209b17ba378 (patch)
treeef06a674df6c4fb642331c2f137315e1de5460e8 /include/linux
parente04c78d86a9699d136910cfc0bdcf01087e3267e (diff)
downloadlinux-4bfbc2691de8c869339090e851703209b17ba378.tar.xz
mux: Convert mux_control_ops to a flex array member in mux_chip
Convert mux_control_ops to a flexible array member at the end of the mux_chip struct and add the __counted_by() compiler attribute to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE. Use struct_size() to calculate the number of bytes to allocate for a new mux chip and to remove the following Coccinelle/coccicheck warning: WARNING: Use struct_size Use size_add() to safely add any extra bytes. No functional changes intended. Link: https://github.com/KSPP/linux/issues/83 Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Link: https://lore.kernel.org/r/20250610104106.1948-2-thorsten.blum@linux.dev Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/mux/driver.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/mux/driver.h b/include/linux/mux/driver.h
index 18824064f8c0..e58e59354e23 100644
--- a/include/linux/mux/driver.h
+++ b/include/linux/mux/driver.h
@@ -56,18 +56,18 @@ struct mux_control {
/**
* struct mux_chip - Represents a chip holding mux controllers.
* @controllers: Number of mux controllers handled by the chip.
- * @mux: Array of mux controllers that are handled.
* @dev: Device structure.
* @id: Used to identify the device internally.
* @ops: Mux controller operations.
+ * @mux: Array of mux controllers that are handled.
*/
struct mux_chip {
unsigned int controllers;
- struct mux_control *mux;
struct device dev;
int id;
const struct mux_control_ops *ops;
+ struct mux_control mux[] __counted_by(controllers);
};
#define to_mux_chip(x) container_of((x), struct mux_chip, dev)