Re: [PATCH 5/6] s390/dcssblk: initialize device semaphore before sysfs registration
From: Heiko Carstens
Date: Wed Oct 28 2026 - 03:03:30 EST
On Wed, Oct 28, 2026 at 12:48:25PM +0800, Jiale Yao wrote:
> device_create_file() makes the add and remove attributes writable before
> the device list semaphore is initialized. A sysfs write racing module
> initialization can therefore acquire an uninitialized rwsem.
>
> Initialize the semaphore before registering the root device and its
> attributes.
>
> Fixes: c369527f18f8 ("[S390] pm: dcssblk power management callbacks.")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
> ---
> drivers/s390/block/dcssblk.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
> index e5a02c2990d0..46dd7eb9ca7d 100644
> --- a/drivers/s390/block/dcssblk.c
> +++ b/drivers/s390/block/dcssblk.c
> @@ -1013,6 +1013,8 @@ dcssblk_init(void)
> {
> int rc;
>
> + init_rwsem(&dcssblk_devices_sem);
> +
> dcssblk_root_dev = root_device_register("dcssblk");
> if (IS_ERR(dcssblk_root_dev))
> return PTR_ERR(dcssblk_root_dev);
> @@ -1026,7 +1028,6 @@ dcssblk_init(void)
> if (rc < 0)
> goto out_root;
> dcssblk_major = rc;
> - init_rwsem(&dcssblk_devices_sem);
I changed this to use a static DECLARE_RWSEM() declaration; and also
removed the incorrect Fixes tag - this is probably broken since the
driver exists.
Applied, thanks!