Re: [PATCH v2] pinctrl: intel: move PWM base computation past feature check

From: Andy Shevchenko

Date: Sun May 17 2026 - 11:48:10 EST


On Sun, May 17, 2026 at 6:40 PM Stepan Ionichev <sozdayvek@xxxxxxxxx> wrote:
>
> intel_pinctrl_probe_pwm() computes the PWM register base unconditionally
> at the start of the function:
>
> void __iomem *base = community->regs + capability_offset + 4;
>
> if (!(community->features & PINCTRL_FEATURE_PWM))
> return 0;
> if (!IS_REACHABLE(CONFIG_PWM_LPSS))
> return 0;
>
> chip = devm_pwm_lpss_probe(pctrl->dev, base, &info);
>
> For communities without CAPLIST_ID_PWM, capability_offset is the
> uninitialised value left in the per-community array on the stack;
> forming base = regs + capability_offset + 4 from that value reads
> indeterminate state even though the result is never dereferenced
> (the feature check returns first).
>
> Split the declaration from the assignment so the value is only
> computed after PINCTRL_FEATURE_PWM and the CONFIG_PWM_LPSS
> reachability check have passed. base is then the same single use
> that devm_pwm_lpss_probe() already consumes, so no other call sites
> are affected.

The commit message is too long for this smaller clean up. Just say
that we want to tidy up the code for better maintenance (it's the only
reason I see for this patch), otherwise you also need to prove that
compiler does some bad things.

...

Code wise okay.

--
With Best Regards,
Andy Shevchenko