]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
pinctrl: starfive: jh7110: Use __counted_by() flexarray
authorLinus Walleij <linusw@kernel.org>
Sun, 17 May 2026 23:01:19 +0000 (01:01 +0200)
committerLinus Walleij <linusw@kernel.org>
Mon, 25 May 2026 08:13:43 +0000 (10:13 +0200)
Flexible arrays should use __counted_by() to be able to do
runtime checks that the array does not go out of range.

Cc: Rosen Penev <rosenp@gmail.com>
Fixes: 87182ef0bf93 ("pinctrl: starfive: jh7110: use struct_size")
Signed-off-by: Linus Walleij <linusw@kernel.org>
drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
drivers/pinctrl/starfive/pinctrl-starfive-jh7110.h

index 3572e8edd9f30410ca95e05e5600de025fa03a94..3fb9aa8ddf074259b919521c7a877bb71be58058 100644 (file)
@@ -865,6 +865,7 @@ int jh7110_pinctrl_probe(struct platform_device *pdev)
 #endif
        if (!sfp)
                return -ENOMEM;
+       sfp->num_saved_regs = info->nsaved_regs;
 
        sfp->base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(sfp->base))
index 188fc9d96269d3df81eec8e51b5e2127ed489c80..12568be2852773d5feea28ee186586b870157d62 100644 (file)
@@ -21,7 +21,8 @@ struct jh7110_pinctrl {
        /* register read/write mutex */
        struct mutex mutex;
        const struct jh7110_pinctrl_soc_info *info;
-       u32 saved_regs[];
+       unsigned int num_saved_regs;
+       u32 saved_regs[] __counted_by(num_saved_regs);
 };
 
 struct jh7110_gpio_irq_reg {