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: <20160921163120.7d7e7fca@bbrezillon>
Date:   Wed, 21 Sep 2016 16:31:20 +0200
From:   Boris Brezillon <boris.brezillon@...e-electrons.com>
To:     Daniel Walter <dwalter@...ma-star.at>
Cc:     linux-mtd@...ts.infradead.org, Richard Weinberger <richard@....at>,
        computersforpeace@...il.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 03/46] mtd: Don't unconditionally unregister reboot
 notifier

On Wed, 21 Sep 2016 11:45:12 +0200
Daniel Walter <dwalter@...ma-star.at> wrote:

> From: Richard Weinberger <richard@....at>
> 
> del_mtd_device() is allowed to fail.
> i.e. when the MTD is busy.
> Unregister the reboot notifier only when we're really
> about to delete the MTD.
> 
> Signed-off-by: Richard Weinberger <richard@....at>
> ---
>  drivers/mtd/mtdcore.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index e3936b8..36e5fb0 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -654,17 +654,22 @@ int mtd_device_unregister(struct mtd_info *master)
>  {
>  	int err;
>  
> -	if (master->_reboot)
> -		unregister_reboot_notifier(&master->reboot_notifier);
> -
>  	err = del_mtd_partitions(master);
>  	if (err)
>  		return err;
>  
>  	if (!device_is_registered(&master->dev))
> -		return 0;
> +		goto unregister;
>  
> -	return del_mtd_device(master);
> +	err = del_mtd_device(master);
> +	if (err)
> +		return err;
> +
> +unregister:
> +	if (master->_reboot)
> +		unregister_reboot_notifier(&master->reboot_notifier);
> +
> +	return 0;

How about:

	if (device_is_registered(&master->dev)) {
		err = del_mtd_device(master);
		if (err)
			return err;
	}

	if (master->_reboot)
		unregister_reboot_notifier(&master->reboot_notifier);

	return 0;

This way you get rid of the unregister label, which IMHO improves
readability.

>  }
>  EXPORT_SYMBOL_GPL(mtd_device_unregister);
>  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ