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: <20080130113257.53555fee@gondolin.boeblingen.de.ibm.com>
Date:	Wed, 30 Jan 2008 11:32:57 +0100
From:	Cornelia Huck <cornelia.huck@...ibm.com>
To:	Dave Young <hidave.darkstar@...il.com>
Cc:	gregkh@...e.de, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] driver-core : get_device before create/remove sysfs
 files

On Wed, 30 Jan 2008 09:56:25 +0800,
Dave Young <hidave.darkstar@...il.com> wrote:

> get dev reference before create/remove sysfiles, errno fixes as well.
> 
> Signed-off-by: Dave Young <hidave.darkstar@...il.com> 
> 
> ---
> drivers/base/core.c |   12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff -upr a/drivers/base/core.c b/drivers/base/core.c
> --- a/drivers/base/core.c	2008-01-30 09:49:56.000000000 +0800
> +++ b/drivers/base/core.c	2008-01-30 09:49:56.000000000 +0800
> @@ -414,7 +414,7 @@ struct kset *devices_kset;
>   */
>  int device_create_file(struct device *dev, struct device_attribute *attr)
>  {
> -	int error = 0;
> +	int error = -ENODEV;

Uhm... why?

>  	if (get_device(dev)) {
>  		error = sysfs_create_file(&dev->kobj, &attr->attr);
>  		put_device(dev);
> @@ -442,9 +442,11 @@ void device_remove_file(struct device *d
>   */
>  int device_create_bin_file(struct device *dev, struct bin_attribute *attr)
>  {
> -	int error = -EINVAL;
> -	if (dev)
> +	int error = -ENODEV;
> +	if (get_device(dev)) {
>  		error = sysfs_create_bin_file(&dev->kobj, attr);
> +		put_device(dev);
> +	}

Why do we need to grab a reference here? If the calling site doesn't
hold unto a reference already, something is seriously broken.

>  	return error;
>  }
>  EXPORT_SYMBOL_GPL(device_create_bin_file);
> @@ -456,8 +458,10 @@ EXPORT_SYMBOL_GPL(device_create_bin_file
>   */
>  void device_remove_bin_file(struct device *dev, struct bin_attribute *attr)
>  {
> -	if (dev)
> +	if (get_device(dev)) {
>  		sysfs_remove_bin_file(&dev->kobj, attr);
> +		put_device(dev);
> +	}

Dito.

>  }
>  EXPORT_SYMBOL_GPL(device_remove_bin_file);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ