From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
LKML <linux-kernel@vger.kernel.org>,
linux-rtc@vger.kernel.org, Linux PM <linux-pm@vger.kernel.org>
Subject: [PATCH v1 3/7] ACPI: TAD: Use __free() for cleanup in time_store()
Date: Wed, 04 Mar 2026 19:14:01 +0100 [thread overview]
Message-ID: <13971300.uLZWGnKmhe@rafael.j.wysocki> (raw)
In-Reply-To: <5092662.31r3eYUQgx@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-03-04 18:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-04 18:11 [PATCH v1 0/7] ACPI: TAD: Assorted improvements and RTC class device interface Rafael J. Wysocki
2026-03-04 18:12 ` [PATCH v1 1/7] ACPI: TAD: Create one attribute group Rafael J. Wysocki
2026-03-04 18:13 ` [PATCH v1 2/7] ACPI: TAD: Support RTC without wakeup Rafael J. Wysocki
2026-10-07 1:35 ` Daniel Tang
2026-03-04 18:14 ` Rafael J. Wysocki [this message]
2026-03-04 18:14 ` [PATCH v1 4/7] ACPI: TAD: Rearrange RT data validation checking Rafael J. Wysocki
2026-03-04 18:15 ` [PATCH v1 5/7] ACPI: TAD: Clear unused RT data in acpi_tad_set_real_time() Rafael J. Wysocki
2026-03-04 18:16 ` [PATCH v1 6/7] ACPI: TAD: Add RTC class device interface Rafael J. Wysocki
2026-03-05 7:48 ` Alexandre Belloni
2026-03-04 18:16 ` [PATCH v1 7/7] 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=13971300.uLZWGnKmhe@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-rtc@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®