From: Marco Scardovi <scardracs@disroot.org>
To: ilpo.jarvinen@linux.intel.com
Cc: corentin.chary@gmail.com, denis.benato@linux.dev,
hansg@kernel.org, linux-kernel@vger.kernel.org, luke@ljones.dev,
platform-driver-x86@vger.kernel.org,
Marco Scardovi <scardracs@disroot.org>
Subject: [PATCH v3 0/2] platform/x86: asus-armoury: fix init errors and modernize resource management
Date: Fri, 3 Jul 2026 12:31:57 +0200 [thread overview]
Message-ID: <20260703103212.7406-1-scardracs@disroot.org> (raw)
This patch series addresses a Use-After-Free (UAF) vulnerability
and a memory leak during driver initialization in the asus-armoury
driver, and modernizes its memory management.
Patch 1 fixes the UAF and memory leak by propagating the error code
from init_rog_tunables(), deferring the global pointer updates, and
adding a rollback path.
Patch 2 refactors init_rog_tunables() to use the cleanup infrastructure
via __free(kfree) and no_free_ptr() to automate memory management and
prevent future leaks.
Changes in v3:
- Added a second patch to convert init_rog_tunables() to use the
__free(kfree) and no_free_ptr() cleanup helper macros.
- Added #include <linux/cleanup.h>.
Changes in v2:
- Restructured init_rog_tunables() to use local pointers
(ac_rog_tunables, dc_rog_tunables) and only update the global
static asus_armoury.rog_tunables structure once all allocations
have successfully succeeded. This removes the risk of exposing
freed or partially allocated pointers to the global struct.
- Removed redundant assignments to NULL in the error paths. Since
initialization fails and the driver is not loaded, cleaning the
global static pointers to NULL is not necessary.
- In init_rog_tunables(), replaced 'goto err_nomem' with direct
'return -ENOMEM'. The 'err_nomem' label in the original code
printed a generic OOM error message, which is discouraged in the
kernel as the allocator already issues OOM details. Because that
label did not perform rollback cleanup, a direct return is cleaner
and simpler.
- Replaced inline cleanup in asus_fw_init() with a standard goto
rollback block at the end of the function for cleaner error path
styling.
Thread for v2:
https://lore.kernel.org/platform-driver-x86/20260701164333.5219-1-scardracs@disroot.org/
Marco Scardovi (2):
platform/x86: asus-armoury: fix Use-After-Free and memory leak in
driver init
platform/x86: asus-armoury: use cleanup.h to manage tunables
drivers/platform/x86/asus-armoury.c | 46 ++++++++++++++++++-----------
1 file changed, 28 insertions(+), 18 deletions(-)
--
2.55.0
next reply other threads:[~2026-07-03 10:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 10:31 Marco Scardovi [this message]
2026-07-03 10:31 ` [PATCH v3 1/2] platform/x86: asus-armoury: fix Use-After-Free and memory leak in driver init Marco Scardovi
2026-07-07 16:54 ` Ilpo Järvinen
2026-07-03 10:31 ` [PATCH v3 2/2] platform/x86: asus-armoury: use cleanup.h to manage tunables Marco Scardovi
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=20260703103212.7406-1-scardracs@disroot.org \
--to=scardracs@disroot.org \
--cc=corentin.chary@gmail.com \
--cc=denis.benato@linux.dev \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luke@ljones.dev \
--cc=platform-driver-x86@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®