From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
Danilo Krummrich <dakr@kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH v0 2/6] ACPI: TAD: Use __free() for cleanup in time_store()
Date: Sun, 22 Feb 2026 15:16:19 +0100 [thread overview]
Message-ID: <2266821.irdbgypaU6@rafael.j.wysocki> (raw)
In-Reply-To: <4727679.LvFx2qVVIh@rafael.j.wysocki>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Use __free() for the automatic freeing of memory pointed to by local
variable str in time_store() which allows the code to become somewhat
easier to follow.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpi_tad.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
--- a/drivers/acpi/acpi_tad.c
+++ b/drivers/acpi/acpi_tad.c
@@ -167,57 +167,57 @@ static ssize_t time_store(struct device
const char *buf, size_t count)
{
struct acpi_tad_rt rt;
- char *str, *s;
- int val, ret = -ENODATA;
+ int val, ret;
+ char *s;
- str = kmemdup_nul(buf, count, GFP_KERNEL);
+ char *str __free(kfree) = kmemdup_nul(buf, count, GFP_KERNEL);
if (!str)
return -ENOMEM;
s = acpi_tad_rt_next_field(str, &val);
if (!s)
- goto out_free;
+ return -ENODATA;
rt.year = val;
s = acpi_tad_rt_next_field(s, &val);
if (!s)
- goto out_free;
+ return -ENODATA;
rt.month = val;
s = acpi_tad_rt_next_field(s, &val);
if (!s)
- goto out_free;
+ return -ENODATA;
rt.day = val;
s = acpi_tad_rt_next_field(s, &val);
if (!s)
- goto out_free;
+ return -ENODATA;
rt.hour = val;
s = acpi_tad_rt_next_field(s, &val);
if (!s)
- goto out_free;
+ return -ENODATA;
rt.minute = val;
s = acpi_tad_rt_next_field(s, &val);
if (!s)
- goto out_free;
+ return -ENODATA;
rt.second = val;
s = acpi_tad_rt_next_field(s, &val);
if (!s)
- goto out_free;
+ return -ENODATA;
rt.tz = val;
if (kstrtoint(s, 10, &val))
- goto out_free;
+ return -ENODATA;
rt.daylight = val;
@@ -226,10 +226,10 @@ static ssize_t time_store(struct device
memset(rt.padding, 0, 3);
ret = acpi_tad_set_real_time(dev, &rt);
+ if (ret)
+ return ret;
-out_free:
- kfree(str);
- return ret ? ret : count;
+ return count;
}
static ssize_t time_show(struct device *dev, struct device_attribute *attr,
next prev parent reply other threads:[~2026-02-22 14:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-22 14:14 [PATCH v0 0/6] ACPI: TAD: Assorted improvements and RTC class device interface Rafael J. Wysocki
2026-02-22 14:15 ` [PATCH v0 1/6] ACPI: TAD: Create one attribute group Rafael J. Wysocki
2026-02-22 14:16 ` Rafael J. Wysocki [this message]
2026-02-22 14:17 ` [PATCH v0 3/6] ACPI: TAD: Update RT data validation checking Rafael J. Wysocki
2026-02-22 14:17 ` [PATCH v0 4/6] ACPI: TAD: Clear unused RT data in acpi_tad_set_real_time() Rafael J. Wysocki
2026-02-22 14:18 ` [PATCH v0 5/6] ACPI: TAD: Add RTC class device interface Rafael J. Wysocki
2026-02-27 10:37 ` Alexandre Belloni
2026-02-27 11:26 ` Rafael J. Wysocki
2026-02-22 14:19 ` [PATCH v0 6/6] ACPI: TAD: Update the driver description comment Rafael J. Wysocki
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=2266821.irdbgypaU6@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=dakr@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.