From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Bastian Germann <bastiangermann@fishpost.de>
Cc: Guenter Roeck <linux@roeck-us.net>,
Luca Tettamanti <kronos.it@gmail.com>,
Jean Delvare <jdelvare@suse.com>,
linux-hwmon@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] hwmon: (asus_atk0110) Make use of device managed memory
Date: Fri, 1 Jun 2018 12:54:04 +0300 [thread overview]
Message-ID: <CAHp75VcZqpQ7qM2aBzSsqa+xYOdevZkWy=h+u8=nhdP2foyH4g@mail.gmail.com> (raw)
In-Reply-To: <20180531225700.721-2-bastiangermann@fishpost.de>
On Fri, Jun 1, 2018 at 1:57 AM, Bastian Germann
<bastiangermann@fishpost.de> wrote:
> Use devm_* variants of kstrdup and kzalloc. Get rid of the kfree cleanups.
> static int atk_debugfs_ggrp_open(struct inode *inode, struct file *file)
> {
> struct atk_data *data = inode->i_private;
> + struct device *dev = &data->acpi_dev->dev;
> char *buf = NULL;
> union acpi_object *ret;
> u8 cls;
> @@ -748,7 +748,7 @@ static int atk_debugfs_ggrp_open(struct inode *inode, struct file *file)
> id = &pack->package.elements[0];
> if (id->integer.value == data->debugfs.id) {
> /* Print the package */
> - buf = kzalloc(512, GFP_KERNEL);
> + buf = devm_kzalloc(dev, 512, GFP_KERNEL);
> if (!buf) {
> ACPI_FREE(ret);
> return -ENOMEM;
Looking to the function name, it feels like you are creating a memory
leak and devm_ is inappropriate here.
> @@ -776,16 +776,9 @@ static ssize_t atk_debugfs_ggrp_read(struct file *file, char __user *buf,
> return simple_read_from_buffer(buf, count, pos, str, len);
> }
>
> -static int atk_debugfs_ggrp_release(struct inode *inode, struct file *file)
> -{
> - kfree(file->private_data);
> - return 0;
> -}
> -
> static const struct file_operations atk_debugfs_ggrp_fops = {
> .read = atk_debugfs_ggrp_read,
> .open = atk_debugfs_ggrp_open,
> - .release = atk_debugfs_ggrp_release,
> .llseek = no_llseek,
> };
So do these.
Also the question of time to leave of the objects used for debugfs
communication. Please double check that it's not affected by the
change.
Otherwise looks good.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2018-06-01 9:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-31 14:01 [PATCH 1/2] hwmon: (asus_atk0110) Replace deprecated device register call Bastian Germann
2018-05-31 14:01 ` [PATCH 2/2] hwmon: (asus_atk0110) Remove unused manual sysfs file management Bastian Germann
2018-05-31 14:28 ` Guenter Roeck
2018-05-31 14:27 ` [PATCH 1/2] hwmon: (asus_atk0110) Replace deprecated device register call Guenter Roeck
2018-05-31 22:56 ` Bastian Germann
2018-05-31 22:57 ` [PATCH 2/2] hwmon: (asus_atk0110) Make use of device managed memory Bastian Germann
2018-06-01 9:54 ` Andy Shevchenko [this message]
2018-06-01 11:07 ` [PATCH 1/2] hwmon: (asus_atk0110) Replace deprecated device register call Bastian Germann
2018-06-01 11:07 ` [PATCH 2/2] hwmon: (asus_atk0110) Make use of device managed memory Bastian Germann
2018-06-01 13:28 ` [PATCH 1/2] hwmon: (asus_atk0110) Replace deprecated device register call Guenter Roeck
2018-06-01 15:14 ` asus_atk0110: Use non-deprecated registration and managed memory Bastian Germann
2018-06-01 15:14 ` [PATCH v4 1/2] hwmon: (asus_atk0110) Replace deprecated device register call Bastian Germann
2018-06-01 16:35 ` Guenter Roeck
2018-06-04 20:35 ` Luca Tettamanti
2018-06-01 15:14 ` [PATCH v4 2/2] hwmon: (asus_atk0110) Make use of device managed memory Bastian Germann
2018-06-01 16:40 ` Guenter Roeck
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='CAHp75VcZqpQ7qM2aBzSsqa+xYOdevZkWy=h+u8=nhdP2foyH4g@mail.gmail.com' \
--to=andy.shevchenko@gmail.com \
--cc=bastiangermann@fishpost.de \
--cc=jdelvare@suse.com \
--cc=kronos.it@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/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;
as well as URLs for NNTP newsgroup(s).