lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VcZqpQ7qM2aBzSsqa+xYOdevZkWy=h+u8=nhdP2foyH4g@mail.gmail.com>
Date:   Fri, 1 Jun 2018 12:54:04 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Bastian Germann <bastiangermann@...hpost.de>
Cc:     Guenter Roeck <linux@...ck-us.net>,
        Luca Tettamanti <kronos.it@...il.com>,
        Jean Delvare <jdelvare@...e.com>, linux-hwmon@...r.kernel.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] hwmon: (asus_atk0110) Make use of device managed memory

On Fri, Jun 1, 2018 at 1:57 AM, Bastian Germann
<bastiangermann@...hpost.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ