mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
regmap: debugfs: Use __free(kfree) in regmap_name_read_file()
Use the __free(kfree) cleanup helper for the temporary buffer allocated by regmap_name_read_file(). Remove the explicit kfree() calls from the error and success paths. No functional change. Signed-off-by: Peng Fan <peng.fan@nxp.com> Link: https://patch.msgid.link/20261002-regmap-lock-2nd-v2-6-e172b0501c52@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
ca685a42b0
commit
d64967dee8
|
|
@ -38,10 +38,9 @@ static ssize_t regmap_name_read_file(struct file *file,
|
|||
{
|
||||
struct regmap *map = file->private_data;
|
||||
const char *name = "nodev";
|
||||
char *buf __free(kfree) = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
||||
int ret;
|
||||
char *buf;
|
||||
|
||||
buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -49,14 +48,10 @@ static ssize_t regmap_name_read_file(struct file *file,
|
|||
name = map->dev->driver->name;
|
||||
|
||||
ret = snprintf(buf, PAGE_SIZE, "%s\n", name);
|
||||
if (ret >= PAGE_SIZE) {
|
||||
kfree(buf);
|
||||
if (ret >= PAGE_SIZE)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
|
||||
kfree(buf);
|
||||
return ret;
|
||||
return simple_read_from_buffer(user_buf, count, ppos, buf, ret);
|
||||
}
|
||||
|
||||
static const struct file_operations regmap_name_fops = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user