Re: [PATCH v2 6/6] pinctrl: mediatek: Prevent divide-by-zero for pins with fixed drive strength
From: Linus Walleij
Date: Wed Nov 25 2026 - 13:36:11 EST
On Thu, Nov 19, 2026 at 9:48 PM Lee Jones <lee@xxxxxxxxxx> 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@xxxxxxxxxxxxxxx
> Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
Patch applied!
Yours,
Linus Walleij