Re: [PATCH] usb: typec: ucsi: Fix NULL pointer dereference in power level debugfs

From: Huang Wei

Date: Sun Nov 22 2026 - 21:44:01 EST


On Sat, Nov 21, 2026 at 04:08:13PM +0000, Bertrand Jacquin wrote:
> ucsi->connector never transitions back to NULL. only ucsi_init() writes to
> it through ucsi->work where it's assigned only once, after all ports are
> registered. Every failure path before that assignment leaves it NULL and
> never cleared afterwards.

I re-verified this in the current source and it checks out, including
the -EPROBE_DEFER retry path: each ucsi_init() run works on a local
allocation, and ucsi->connector is only assigned once all ports have
registered, so a retry cannot leave a stale pointer either.

> The only end of its lifetime is ucsi_unregister(), which calls
> ucsi_debugfs_unregister() before kfree(ucsi->connector).

Confirmed. ucsi_unregister() cancels the init work first, then calls
ucsi_debugfs_unregister() before kfree(ucsi->connector), and the
debugfs SRCU drain makes sure a show callback has either finished
before the array is freed, or fails with -EIO afterwards.

So the only transition a reader can race with is NULL -> valid, and
for that direction the check is enough. My Reviewed-by stands.