From: "Hou Wenlong" <houwenlong.hwl@antgroup.com>
To: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
D Scott Phillips <scott@os.amperecomputing.com>,
linux-kernel@vger.kernel.org, kernel-dev@igalia.com,
kernel test robot <oliver.sang@intel.com>
Subject: Re: [PATCH] char: misc: register chrdev region with all possible minors
Date: Fri, 21 Mar 2025 13:55:48 +0800 [thread overview]
Message-ID: <20250321055548.GA106825@k08j02272.eu95sqa> (raw)
In-Reply-To: <20250317-misc-chrdev-v1-1-6cd05da11aef@igalia.com>
On Mon, Mar 17, 2025 at 10:59:55AM -0300, Thadeu Lima de Souza Cascardo wrote:
> register_chrdev will only register the first 256 minors of a major chrdev.
> That means that dynamically allocated misc devices with minor above 255
> will fail to open with -ENXIO.
>
> This was found by kernel test robot when testing a different change that
> makes all dynamically allocated minors be above 255. This has, however,
> been separately tested by creating 256 serio_raw devices with the help of
> userio driver.
>
> Ever since allowing misc devices with minors above 128, this has been
> possible.
>
> Fix it by registering all minor numbers from 0 to MINORMASK + 1 for
> MISC_MAJOR.
>
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202503171507.6c8093d0-lkp@intel.com
> Fixes: ab760791c0cf ("char: misc: Increase the maximum number of dynamic misc devices to 1048448")
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
> ---
> drivers/char/misc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/char/misc.c b/drivers/char/misc.c
> index f7dd455dd0dd3c7c9956e772b5ab8bd83a67a4a6..dda466f9181acf76564b5e41ed6e858928e56182 100644
> --- a/drivers/char/misc.c
> +++ b/drivers/char/misc.c
> @@ -315,7 +315,7 @@ static int __init misc_init(void)
> goto fail_remove;
>
> err = -EIO;
> - if (register_chrdev(MISC_MAJOR, "misc", &misc_fops))
> + if (__register_chrdev(MISC_MAJOR, 0, MINORMASK + 1, "misc", &misc_fops))
> goto fail_printk;
> return 0;
>
>
> ---
> base-commit: 2dc25093218f5d42391549de6fe45e1aa9325676
> change-id: 20250317-misc-chrdev-b26b572a47fc
>
> Best regards,
> --
> Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
>
>
Thank you for the fixes; we encountered the same problem in our
environment as well.
Tested-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
prev parent reply other threads:[~2025-03-21 6:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 13:59 Thadeu Lima de Souza Cascardo
2025-03-21 5:55 ` Hou Wenlong [this message]
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=20250321055548.GA106825@k08j02272.eu95sqa \
--to=houwenlong.hwl@antgroup.com \
--cc=arnd@arndb.de \
--cc=cascardo@igalia.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-dev@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oliver.sang@intel.com \
--cc=scott@os.amperecomputing.com \
/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®