mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chao Huang <958028483@qq.com>
To: gregkh@linuxfoundation.org, cmllamas@google.com
Cc: aliceryhl@google.com, arve@android.com, tkjos@android.com,
	brauner@kernel.org, linux-kernel@vger.kernel.org,
	Chao Huang <huangchao@kylinos.cn>
Subject: [PATCH v5] rust_binder: free minor on binder-control creation failure
Date: Sun, 29 Nov 2026 22:45:19 +0800	[thread overview]
Message-ID: <tencent_1A58B9876E7CB92D87222EF73098C40AAF05@qq.com> (raw)
In-Reply-To: <2026112915-cyclic-cadet-1924@gregkh>

From: Chao Huang <huangchao@kylinos.cn>

The binderfs_binder_ctl_create() implementation in rust_binderfs.c
allocates a minor before creating the binder-control dentry. If
d_alloc_name() fails, the error path frees the device and drops the
inode, but leaves the minor allocated in binderfs_minors. Repeated
failures can therefore exhaust the global minor IDA.

Release the minor from a dedicated error path after a successful
allocation.

Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
Acked-by: Carlos Llamas <cmllamas@google.com>
Signed-off-by: Chao Huang <huangchao@kylinos.cn>
---
v4 -> v5:
- Change the subject prefix to rust_binder and include the complete
  revision history.

v3 -> v4:
- Update only rust_binderfs.c because drivers/android/binderfs.c has been
  removed from the current tree.

v2 -> v3:
- Use a dedicated out_with_minor error path instead of an -ENOSPC sentinel.

v1 -> v2:
- Apply the same fix to drivers/android/binder/rust_binderfs.c.

 drivers/android/binder/rust_binderfs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/android/binder/rust_binderfs.c b/drivers/android/binder/rust_binderfs.c
index 5f020226720d..47c4ca9ea74d 100644
--- a/drivers/android/binder/rust_binderfs.c
+++ b/drivers/android/binder/rust_binderfs.c
@@ -427,7 +427,7 @@ static int binderfs_binder_ctl_create(struct super_block *sb)
 
 	dentry = d_alloc_name(root, "binder-control");
 	if (!dentry)
-		goto out;
+		goto out_with_minor;
 
 	inode->i_private = device;
 	info->control_dentry = dentry;
@@ -436,6 +436,11 @@ static int binderfs_binder_ctl_create(struct super_block *sb)
 
 	return 0;
 
+out_with_minor:
+	mutex_lock(&binderfs_minors_mutex);
+	ida_free(&binderfs_minors, minor);
+	mutex_unlock(&binderfs_minors_mutex);
+
 out:
 	kfree(device);
 	iput(inode);
-- 
2.54.0 (Apple Git-157)


      reply	other threads:[~2026-11-29 14:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 11:23 [PATCH] binderfs: " Chao Huang
2026-08-08 13:34 ` Alice Ryhl
2026-08-10  9:32   ` [PATCH v2] " Chao Huang
2026-08-10 20:16     ` Carlos Llamas
2026-08-11  1:05       ` [PATCH v3] " Chao Huang
2026-08-11  2:52         ` Carlos Llamas
2026-11-29 13:27         ` [PATCH v4] " Chao Huang
2026-11-29 13:33           ` Greg KH
2026-11-29 14:45             ` Chao Huang [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=tencent_1A58B9876E7CB92D87222EF73098C40AAF05@qq.com \
    --to=958028483@qq.com \
    --cc=aliceryhl@google.com \
    --cc=arve@android.com \
    --cc=brauner@kernel.org \
    --cc=cmllamas@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=huangchao@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tkjos@android.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®