From: Jinmo Yang <jinmo44.yang@gmail.com>
To: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Cc: jikos@kernel.org, benjamin.tissoires@redhat.com,
stable@vger.kernel.org, jinmo44.yang@gmail.com
Subject: [PATCH v2 2/2] HID: wacom: use cleanup.h for wacom_wac_queue_flush() buffer management
Date: Mon, 1 Jun 2026 22:41:24 +0900 [thread overview]
Message-ID: <20260601134124.1560886-3-jinmo44.yang@gmail.com> (raw)
In-Reply-To: <20260601134124.1560886-1-jinmo44.yang@gmail.com>
Use __free(kfree) cleanup facility for the temporary buffer in
wacom_wac_queue_flush() to simplify error paths and ensure the buffer
is freed automatically when it goes out of scope.
Signed-off-by: Jinmo Yang <jinmo44.yang@gmail.com>
---
drivers/hid/wacom_sys.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 2e237bdd2..edc24fe2e 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -70,11 +70,10 @@ static void wacom_wac_queue_flush(struct hid_device *hdev,
{
while (!kfifo_is_empty(fifo)) {
int size = kfifo_peek_len(fifo);
- u8 *buf;
+ u8 *buf __free(kfree) = kzalloc(size, GFP_ATOMIC);
unsigned int count;
int err;
- buf = kzalloc(size, GFP_ATOMIC);
if (!buf) {
kfifo_skip(fifo);
continue;
@@ -87,7 +86,6 @@ static void wacom_wac_queue_flush(struct hid_device *hdev,
// to flush seems reasonable enough, however.
hid_warn(hdev, "%s: removed fifo entry with unexpected size\n",
__func__);
- kfree(buf);
continue;
}
err = hid_report_raw_event(hdev, HID_INPUT_REPORT, buf, size, size, false);
@@ -95,8 +93,6 @@ static void wacom_wac_queue_flush(struct hid_device *hdev,
hid_warn(hdev, "%s: unable to flush event due to error %d\n",
__func__, err);
}
-
- kfree(buf);
}
}
--
2.53.0
next prev parent reply other threads:[~2026-06-01 13:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260530155930.128183-1-jinmo44.yang@gmail.com>
2026-05-30 16:16 ` [PATCH] HID: wacom: use GFP_ATOMIC in wacom_wac_queue_flush() sashiko-bot
2026-05-31 4:25 ` Dmitry Torokhov
2026-06-01 13:41 ` [PATCH v2 0/2] HID: wacom: fix sleeping in atomic context " Jinmo Yang
2026-06-01 13:41 ` [PATCH v2 1/2] HID: wacom: use GFP_ATOMIC " Jinmo Yang
2026-06-01 13:41 ` Jinmo Yang [this message]
2026-06-01 18:19 ` [PATCH v2 0/2] HID: wacom: fix sleeping in atomic context " Benjamin Tissoires
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=20260601134124.1560886-3-jinmo44.yang@gmail.com \
--to=jinmo44.yang@gmail.com \
--cc=benjamin.tissoires@redhat.com \
--cc=dmitry.torokhov@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.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