public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Cc: linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dirk VanDerMerwe <dirk.vandermerwe@sophos.com>,
	Vimal Agrawal <vimal.agrawal@sophos.com>,
	kernel-dev@igalia.com, stable@vger.kernel.org
Subject: Re: [PATCH 4/4] char: misc: deallocate static minor in error path
Date: Thu, 20 Feb 2025 13:11:17 +0100	[thread overview]
Message-ID: <2025022041-onyx-regular-d901@gregkh> (raw)
In-Reply-To: <20250123123249.4081674-5-cascardo@igalia.com>

On Thu, Jan 23, 2025 at 09:32:49AM -0300, Thadeu Lima de Souza Cascardo wrote:
> When creating sysfs files fail, the allocated minor must be freed such that
> it can be later reused. That is specially harmful for static minor numbers,
> since those would always fail to register later on.
> 
> Fixes: 6d04d2b554b1 ("misc: misc_minor_alloc to use ida for all dynamic/misc dynamic minors")
> Cc: stable@vger.kernel.org
> 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 7a768775e558..7843a1a34d64 100644
> --- a/drivers/char/misc.c
> +++ b/drivers/char/misc.c
> @@ -266,8 +266,8 @@ int misc_register(struct miscdevice *misc)
>  		device_create_with_groups(&misc_class, misc->parent, dev,
>  					  misc, misc->groups, "%s", misc->name);
>  	if (IS_ERR(misc->this_device)) {
> +		misc_minor_free(misc->minor);
>  		if (is_dynamic) {
> -			misc_minor_free(misc->minor);
>  			misc->minor = MISC_DYNAMIC_MINOR;
>  		}
>  		err = PTR_ERR(misc->this_device);
> -- 
> 2.34.1
> 
> 

Having a "fix" as patch 4/4 of a series is a pain, it should go to Linus
now, not for the next merge window, right?  I'll split this apart by
hand, but ugh, please be more careful next time.

thanks,

greg k-h

      reply	other threads:[~2025-02-20 12:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-23 12:32 [PATCH 0/4] char: misc: improve test and dynamic allocation Thadeu Lima de Souza Cascardo
2025-01-23 12:32 ` [PATCH 1/4] char: misc: improve testing Kconfig description Thadeu Lima de Souza Cascardo
2025-01-23 12:32 ` [PATCH 2/4] char: misc: add test cases Thadeu Lima de Souza Cascardo
2025-02-20 14:32   ` Greg Kroah-Hartman
2025-01-23 12:32 ` [PATCH 3/4] char: misc: restrict the dynamic range to exclude reserved minors Thadeu Lima de Souza Cascardo
2025-02-20 14:31   ` Greg Kroah-Hartman
2025-02-20 14:52     ` Thadeu Lima de Souza Cascardo
2025-02-20 15:05       ` Greg Kroah-Hartman
2025-01-23 12:32 ` [PATCH 4/4] char: misc: deallocate static minor in error path Thadeu Lima de Souza Cascardo
2025-02-20 12:11   ` Greg Kroah-Hartman [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=2025022041-onyx-regular-d901@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=cascardo@igalia.com \
    --cc=dirk.vandermerwe@sophos.com \
    --cc=kernel-dev@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vimal.agrawal@sophos.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