Re: [PATCH] posix-clock: initialize cdev state before publishing
From: Frederic Weisbecker
Date: Thu Nov 19 2026 - 11:29:27 EST
Le Mon, Nov 16, 2026 at 11:28:53AM +0800, Haoli Zhang a écrit :
> cdev_device_add() may expose the cdev before it returns. Initialize
> clk->cdev.owner and clk->dev before calling it, so an open racing with
> registration takes the matching module and device references.
>
> If cdev_device_add() fails after cdev_add() made the cdev available,
> open files may still exist. Mark the clock as a zombie under rwsem before
> returning the error, so subsequent read, poll, ioctl, and dynamic clock
> operations on those files fail while the caller tears down registration
> state. Keep clk->dev valid so the release path can drop any reference
> acquired by a successful open.
Is the device made available before device_add()?
Thanks.
--
Frederic Weisbecker
SUSE Labs