From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Masahiro Yamada <masahiroy@kernel.org>,
Randy Dunlap <rdunlap@infradead.org>,
Sasha Levin <sashal@kernel.org>,
linux-kbuild@vger.kernel.org
Subject: [PATCH AUTOSEL 6.16-5.4] kconfig: gconf: fix potential memory leak in renderer_edited()
Date: Sat, 9 Aug 2025 20:20:54 -0400 [thread overview]
Message-ID: <20250810002104.1545396-5-sashal@kernel.org> (raw)
In-Reply-To: <20250810002104.1545396-1-sashal@kernel.org>
From: Masahiro Yamada <masahiroy@kernel.org>
[ Upstream commit f72ed4c6a375e52a3f4b75615e4a89d29d8acea7 ]
If gtk_tree_model_get_iter() fails, gtk_tree_path_free() is not called.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
Based on my analysis of the commit and examination of the code, here is
my assessment:
**Backport Status: YES**
## Extensive Analysis:
### 1. **Nature of the Bug**
The commit fixes a clear memory leak in the `renderer_edited()` function
in scripts/kconfig/gconf.c. The function allocates a GtkTreePath object
using `gtk_tree_path_new_from_string()` at line 782, but if
`gtk_tree_model_get_iter()` fails on line 788, the function returns
early without calling `gtk_tree_path_free()`, causing a memory leak.
### 2. **Bug Impact**
- **Resource leak**: Every time a user attempts to edit a value in the
GTK-based kernel configuration tool (gconfig) and the operation fails
to get the iterator, memory is leaked.
- **User-facing impact**: While gconfig is not used by all kernel users,
those who do use it for configuring the kernel could experience memory
leaks during interactive configuration sessions.
- **Accumulation potential**: In a long configuration session with
multiple failed edits, these leaks could accumulate.
### 3. **Fix Analysis**
The fix is minimal and straightforward:
- Changes the early `return` to a `goto free` statement
- Adds a `free:` label before the existing `gtk_tree_path_free(path)`
call
- This ensures the allocated path is always freed, whether the function
succeeds or fails
### 4. **Risk Assessment**
- **Minimal risk**: The change only affects the error path and ensures
proper cleanup
- **No functional changes**: The fix doesn't alter any program logic, it
only adds proper resource cleanup
- **Well-contained**: The change is limited to a single function in the
gconfig tool
- **Standard pattern**: Using goto for cleanup is a common and accepted
pattern in kernel code
### 5. **Stable Tree Criteria Compliance**
The commit meets stable tree requirements:
- ✓ Fixes a real bug (memory leak)
- ✓ Small and contained (2 lines changed)
- ✓ No new features or architectural changes
- ✓ Clear and obvious correctness
- ✓ Minimal regression risk
### 6. **Historical Context**
Looking at the git history, there have been multiple memory leak fixes
in the kconfig subsystem (e.g., commits a409fc1463d6, ae1eff0349f2,
fbac5977d81c), indicating this is an area where such fixes are
considered important and regularly backported.
### 7. **Code Pattern Analysis**
Examining other uses of `gtk_tree_model_get_iter()` in the same file
shows that other call sites don't have this issue because they either:
- Don't allocate resources before the call (lines 902, 962, 1015)
- Or are in different contexts where the path is managed differently
This makes the fix in `renderer_edited()` particularly important as it's
the only place with this specific leak pattern.
The commit should be backported to stable kernels to ensure users of the
gconfig tool don't experience memory leaks during kernel configuration
sessions.
scripts/kconfig/gconf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index abe4cfe66b14..0caf0ced13df 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -748,7 +748,7 @@ static void renderer_edited(GtkCellRendererText * cell,
struct symbol *sym;
if (!gtk_tree_model_get_iter(model2, &iter, path))
- return;
+ goto free;
gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
sym = menu->sym;
@@ -760,6 +760,7 @@ static void renderer_edited(GtkCellRendererText * cell,
update_tree(&rootmenu, NULL);
+free:
gtk_tree_path_free(path);
}
--
2.39.5
next prev parent reply other threads:[~2025-08-10 0:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-10 0:20 [PATCH AUTOSEL 6.16-5.4] kconfig: gconf: avoid hardcoding model2 in on_treeview2_cursor_changed() Sasha Levin
2025-08-10 0:20 ` [PATCH AUTOSEL 6.16-6.15] kheaders: rebuild kheaders_data.tar.xz when a file is modified within a minute Sasha Levin
2025-08-10 0:20 ` [PATCH AUTOSEL 6.16-5.4] kconfig: lxdialog: fix 'space' to (de)select options Sasha Levin
2025-08-10 0:20 ` [PATCH AUTOSEL 6.16-5.4] scsi: aacraid: Stop using PCI_IRQ_AFFINITY Sasha Levin
2025-08-10 0:20 ` Sasha Levin [this message]
2025-08-10 0:20 ` [PATCH AUTOSEL 6.16-5.15] scsi: target: core: Generate correct identifiers for PR OUT transport IDs Sasha Levin
2025-08-10 0:20 ` [PATCH AUTOSEL 6.16-5.4] ipmi: Fix strcpy source and destination the same Sasha Levin
2025-08-10 0:20 ` [PATCH AUTOSEL 6.16-5.4] scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans Sasha Levin
2025-08-10 0:20 ` [PATCH AUTOSEL 6.16-6.1] vfio/mlx5: fix possible overflow in tracking max message size Sasha Levin
2025-08-10 0:20 ` [PATCH AUTOSEL 6.16-5.4] kconfig: nconf: Ensure null termination where strncpy is used Sasha Levin
2025-08-10 0:21 ` [PATCH AUTOSEL 6.16-5.4] kconfig: lxdialog: replace strcpy() with strncpy() in inputbox.c Sasha Levin
2025-08-10 0:21 ` [PATCH AUTOSEL 6.16-5.15] vfio/type1: conditional rescheduling while pinning Sasha Levin
2025-08-10 0:21 ` [PATCH AUTOSEL 6.16-5.4] ipmi: Use dev_warn_ratelimited() for incorrect message warnings Sasha Levin
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=20250810002104.1545396-5-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=patches@lists.linux.dev \
--cc=rdunlap@infradead.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