From: Jiale Yao <yaojiale02@163.com>
To: Ioana Ciornei <ioana.ciornei@nxp.com>,
Laurentiu Tudor <laurentiu.tudor@nxp.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 2/6] bus: fsl-mc: initialize UAPI state before device registration
Date: Wed, 28 Oct 2026 12:48:22 +0800 [thread overview]
Message-ID: <20261028044828.96177-3-yaojiale02@163.com> (raw)
In-Reply-To: <20261028044828.96177-1-yaojiale02@163.com>
misc_register() exposes the fsl-mc UAPI device before its mutex and
static portal pointer are initialized. A userspace open racing device
creation can consequently lock an uninitialized mutex or observe
incomplete state.
Initialize the UAPI state before registering the misc device.
Fixes: 2cf1e703f066 ("bus: fsl-mc: add fsl-mc userspace support")
Cc: stable@vger.kernel.org
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/bus/fsl-mc/fsl-mc-uapi.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/bus/fsl-mc/fsl-mc-uapi.c b/drivers/bus/fsl-mc/fsl-mc-uapi.c
index aaa14f17aef4..2c586dd787f3 100644
--- a/drivers/bus/fsl-mc/fsl-mc-uapi.c
+++ b/drivers/bus/fsl-mc/fsl-mc-uapi.c
@@ -586,15 +586,13 @@ int fsl_mc_uapi_create_device_file(struct fsl_mc_bus *mc_bus)
mc_uapi->misc.minor = MISC_DYNAMIC_MINOR;
mc_uapi->misc.name = dev_name(&mc_dev->dev);
mc_uapi->misc.fops = &fsl_mc_uapi_dev_fops;
+ mc_uapi->static_mc_io = mc_bus->mc_dev.mc_io;
+ mutex_init(&mc_uapi->mutex);
error = misc_register(&mc_uapi->misc);
if (error)
return error;
- mc_uapi->static_mc_io = mc_bus->mc_dev.mc_io;
-
- mutex_init(&mc_uapi->mutex);
-
return 0;
}
--
2.34.1
next prev parent reply other threads:[~2026-10-28 4:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 4:48 [PATCH 0/6] Initialize device state before userspace registration Jiale Yao
2026-10-28 4:48 ` [PATCH 1/6] aoe: initialize error message synchronization before registration Jiale Yao
2026-10-28 4:48 ` Jiale Yao [this message]
2026-10-28 4:48 ` [PATCH 3/6] Drivers: hv: initialize partition table before device registration Jiale Yao
2026-10-28 4:48 ` [PATCH 4/6] misc: ibmvmc: initialize HMC state " Jiale Yao
2026-10-28 9:25 ` Arnd Bergmann
2026-10-28 10:05 ` Greg Kroah-Hartman
2026-10-28 4:48 ` [PATCH 5/6] s390/dcssblk: initialize device semaphore before sysfs registration Jiale Yao
2026-10-28 7:03 ` Heiko Carstens
2026-10-28 4:48 ` [PATCH 6/6] watchdog: rdc321x: initialize device state before registration Jiale Yao
2026-10-28 14:53 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261028044828.96177-3-yaojiale02@163.com \
--to=yaojiale02@163.com \
--cc=gregkh@linuxfoundation.org \
--cc=ioana.ciornei@nxp.com \
--cc=laurentiu.tudor@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®