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: <20210329153356.1e817912@jic23-huawei>
Date:   Mon, 29 Mar 2021 15:33:56 +0100
From:   Jonathan Cameron <jic23@...nel.org>
To:     Alexandru Ardelean <aardelean@...iqon.com>
Cc:     platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-iio@...r.kernel.org, coproscefalo@...il.com,
        hdegoede@...hat.com, mgross@...ux.intel.com, linux@...iqon.com
Subject: Re: [PATCH 03/10] platform/x86: toshiba_acpi: bind registration of
 miscdev object to parent

On Wed, 24 Mar 2021 14:55:41 +0200
Alexandru Ardelean <aardelean@...iqon.com> wrote:

> This change moves the registration of the Toshiba ACPI miscdev to be
> handled by the devm_add_action_or_reset() hook. This way, the miscdev will
> be unregistered when the reference count of the parent device object goes
> to zero.
> 
> This also changes the order of cleanup in toshiba_acpi_remove(), where the
> miscdev was deregistered first. Now it will be deregistered right before
> the toshiba_acpi_dev object is free'd.
> 
> Signed-off-by: Alexandru Ardelean <aardelean@...iqon.com>
Reorder looks right to me, but maybe I'm missing something subtle.

Acked-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>

One unrelated comment inline.

Jonathan

> ---
>  drivers/platform/x86/toshiba_acpi.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
> index c5284601bc2a..53ef565378ef 100644
> --- a/drivers/platform/x86/toshiba_acpi.c
> +++ b/drivers/platform/x86/toshiba_acpi.c
> @@ -2963,8 +2963,6 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
>  {
>  	struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
>  
> -	misc_deregister(&dev->miscdev);
> -
>  	remove_toshiba_proc_entries(dev);
>  
>  	if (dev->accelerometer_supported && dev->indio_dev) {
> @@ -3014,6 +3012,13 @@ static void toshiba_acpi_singleton_clear(void *data)
>  	toshiba_acpi = NULL;
>  }
>  
> +static void toshiba_acpi_misc_deregister(void *data)
> +{
> +	struct miscdevice *miscdev = data;
> +
> +	misc_deregister(miscdev);
> +}
> +
>  static int toshiba_acpi_add(struct acpi_device *acpi_dev)
>  {
>  	struct device *parent = &acpi_dev->dev;
> @@ -3056,6 +3061,11 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
>  		return ret;
>  	}
>  
> +	ret = devm_add_action_or_reset(parent, toshiba_acpi_misc_deregister,
> +				       &dev->miscdev);
> +	if (ret)
> +		return ret;
> +
>  	acpi_dev->driver_data = dev;
>  	dev_set_drvdata(&acpi_dev->dev, dev);

Why are we carrying two copies of the same thing? (obviously unrelated
to your patch :)

>  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ