Re: [PATCH] serial: max310x: simplify clock management with devm_clk_get_optional_enabled()

From: Tapio Reijonen

Date: Sun Dec 06 2026 - 02:40:18 EST


On 12/2/26 18:28, Hugo Villeneuve wrote:
> -out_clk:
> - clk_disable_unprepare(s->clk);
> -
> return ret;
> }

Hi Hugo,

This overlaps with patches of mine that are on the list, so two notes.

The use-after-free in max310x_remove() that the Sashiko reply to this
patch points at is what patch 1/3 of this series fixes:

[PATCH 0/3] serial: max310x: teardown ordering and CTS locking fixes
<20261120-max310x-teardown-fixes-v1-0-eb52c8b612df@xxxxxxxxxxx>

Patches 1/3 and 2/3 of it change the same lines as this patch: the end
of max310x_remove() and the error exits of max310x_probe(), where 2/3
sends the exits that come before any port is registered to out_clk.
Patch 1/7 of

[PATCH 0/7] serial: core: Power the line transceiver with the port
<20261111-serial-transceiver-supply-v1-0-40bad0f912f2@xxxxxxxxxxx>

adds two more jumps to out_clk. It applies on top of this patch, but
does not build then, as the label is gone.

With the clock managed by devm those jumps become plain returns, so
the rebase is small in either order. If this patch is applied first I
rebase both series on it.

The change itself looks right to me: the clock is now released by
devres after remove() has returned, and after the gpiochip and the
interrupt, which were requested later in probe.

Reviewed-by: Tapio Reijonen <tapio.reijonen@xxxxxxxxxxx>

If you have time to look at the teardown series, a review would be
very welcome.

Best regards,
Tapio