[PATCH v2 6/6] pinctrl: mediatek: Prevent divide-by-zero for pins with fixed drive strength
Linus Walleij
linusw at kernel.org
Wed Nov 25 10:35:52 PST 2026
On Thu, Nov 19, 2026 at 9:48 PM Lee Jones <lee at kernel.org> wrote:
> mtk_drive[] only defines entries for DRV_GRP0 (1) through DRV_GRP4 (5),
> leaving mtk_drive[DRV_FIXED] (0) zero-initialised with min = 0, max = 0,
> step = 0, and scal = 0. If mtk_pinconf_drive_set() or
> mtk_pinconf_drive_set_rev1() is called with arg = 0 on a pin with
> drv_n == DRV_FIXED, the range check (0 >= 0 && 0 <= 0) succeeds and
> !(arg % tb->step) divides by zero. Similarly, mtk_pinconf_drive_get()
> and mtk_pinconf_drive_get_rev1() divide by tb->scal (0) if the pin has
> drive register fields defined.
>
> Return -ENOTSUPP immediately when desc->drv_n == DRV_FIXED.
>
> Fixes: c28321979ba8 ("pinctrl: mediatek: add driving strength related support to pinctrl-mtk-common-v2.c")
> Closes: https://sashiko.dev/#/bug/linux-d3852d37-6806-4c41-a493-f249dd59d0c6
> Cc: stable at vger.kernel.org
> Signed-off-by: Lee Jones <lee at kernel.org>
Patch applied!
Yours,
Linus Walleij
More information about the linux-arm-kernel
mailing list