mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Hou Wenlong" <houwenlong.hwl@antgroup.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH] char: misc: Use __register_chrdev() to register the actual minor counts
Date: Fri, 21 Mar 2025 14:24:25 +0800	[thread overview]
Message-ID: <20250321062425.GA129980@k08j02272.eu95sqa> (raw)
In-Reply-To: <2025032054-stylus-chemist-1cd4@gregkh>

On Fri, Mar 21, 2025 at 12:44:54PM +0800, Greg Kroah-Hartman wrote:
> On Fri, Mar 21, 2025 at 11:54:42AM +0800, Hou Wenlong wrote:
> > In commit ab760791c0cf ("char: misc: Increase the maximum number of
> > dynamic misc devices to 1048448"), the minor number of misc char device
> > is increased to MINORMASK + 1. However, it still uses register_chrdev(),
> > which defaults to registering the misc char device with only 256 minor
> > numbers.  Therefore, when a misc device is given a minor number greater
> > than 255, the device file fails to open in kobj_lookup(). As a solution,
> > use __register_chrdev() to register the actual minor counts to
> > accommodate this increase.
> > 
> > Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
> > ---
> > In our environment, the per-cpu coresight_tmc driver occupies too many
> > minor numbers, which ultimately allocates minor number 256 for our misc
> > device, resulting in a failure to open the device file in /dev. I'm not
> > sure if this is a bug or if userspace can only use fewer than 256 minor
> > numbers. Therefore, I didn't add a fix tag here.
> > ---
> >  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 f7dd455dd0dd..dda466f9181a 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;
> >  
> > -- 
> > 2.31.1
> > 
> 
> I think this is the same change as this one:
> 	https://lore.kernel.org/r/20250317-misc-chrdev-v1-1-6cd05da11aef@igalia.com
> 
> right?
>
Yes, it's the same problem. I have replied to that one. Thank you!
 
> If so, can you provide a reviewed-by or tested-by on that one?  I
> haven't picked it up yet, sorry.
> 
> greg k-h

      reply	other threads:[~2025-03-21  6:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-21  3:54 Hou Wenlong
2025-03-21  4:44 ` Greg Kroah-Hartman
2025-03-21  6:24   ` 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=20250321062425.GA129980@k08j02272.eu95sqa \
    --to=houwenlong.hwl@antgroup.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@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®