Skip to content

Commit e64ab3e

Browse files
committed
ACPI: TAD: Use __free() for cleanup in time_store()
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> Link: https://patch.msgid.link/13971300.uLZWGnKmhe@rafael.j.wysocki
1 parent 6c711fd commit e64ab3e

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

drivers/acpi/acpi_tad.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,57 +167,57 @@ static ssize_t time_store(struct device *dev, struct device_attribute *attr,
167167
const char *buf, size_t count)
168168
{
169169
struct acpi_tad_rt rt;
170-
char *str, *s;
171-
int val, ret = -ENODATA;
170+
int val, ret;
171+
char *s;
172172

173-
str = kmemdup_nul(buf, count, GFP_KERNEL);
173+
char *str __free(kfree) = kmemdup_nul(buf, count, GFP_KERNEL);
174174
if (!str)
175175
return -ENOMEM;
176176

177177
s = acpi_tad_rt_next_field(str, &val);
178178
if (!s)
179-
goto out_free;
179+
return -ENODATA;
180180

181181
rt.year = val;
182182

183183
s = acpi_tad_rt_next_field(s, &val);
184184
if (!s)
185-
goto out_free;
185+
return -ENODATA;
186186

187187
rt.month = val;
188188

189189
s = acpi_tad_rt_next_field(s, &val);
190190
if (!s)
191-
goto out_free;
191+
return -ENODATA;
192192

193193
rt.day = val;
194194

195195
s = acpi_tad_rt_next_field(s, &val);
196196
if (!s)
197-
goto out_free;
197+
return -ENODATA;
198198

199199
rt.hour = val;
200200

201201
s = acpi_tad_rt_next_field(s, &val);
202202
if (!s)
203-
goto out_free;
203+
return -ENODATA;
204204

205205
rt.minute = val;
206206

207207
s = acpi_tad_rt_next_field(s, &val);
208208
if (!s)
209-
goto out_free;
209+
return -ENODATA;
210210

211211
rt.second = val;
212212

213213
s = acpi_tad_rt_next_field(s, &val);
214214
if (!s)
215-
goto out_free;
215+
return -ENODATA;
216216

217217
rt.tz = val;
218218

219219
if (kstrtoint(s, 10, &val))
220-
goto out_free;
220+
return -ENODATA;
221221

222222
rt.daylight = val;
223223

@@ -226,10 +226,10 @@ static ssize_t time_store(struct device *dev, struct device_attribute *attr,
226226
memset(rt.padding, 0, 3);
227227

228228
ret = acpi_tad_set_real_time(dev, &rt);
229+
if (ret)
230+
return ret;
229231

230-
out_free:
231-
kfree(str);
232-
return ret ? ret : count;
232+
return count;
233233
}
234234

235235
static ssize_t time_show(struct device *dev, struct device_attribute *attr,

0 commit comments

Comments
 (0)