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] [day] [month] [year] [list]
Message-ID: <20061004233159.GB16204@kroah.com>
Date:	Wed, 4 Oct 2006 16:31:59 -0700
From:	Greg KH <greg@...ah.com>
To:	Jeff Garzik <jeff@...zik.org>
Cc:	ecashin@...aid.com, Andrew Morton <akpm@...l.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drivers/block/aoe: handle sysfs errors

On Wed, Oct 04, 2006 at 09:58:19AM -0400, Jeff Garzik wrote:
> 
> Signed-off-by: Jeff Garzik <jeff@...zik.org>
> 
> ---
> 
>  drivers/block/aoe/aoeblk.c |   64 +++++++++++++++++++++++++++++++++------------
>  1 files changed, 47 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
> index 393b86a..04f9b03 100644
> --- a/drivers/block/aoe/aoeblk.c
> +++ b/drivers/block/aoe/aoeblk.c
> @@ -64,13 +64,36 @@ static struct disk_attribute disk_attr_f
>  	.show = aoedisk_show_fwver
>  };
>  
> -static void
> +static int
>  aoedisk_add_sysfs(struct aoedev *d)
>  {
> -	sysfs_create_file(&d->gd->kobj, &disk_attr_state.attr);
> -	sysfs_create_file(&d->gd->kobj, &disk_attr_mac.attr);
> -	sysfs_create_file(&d->gd->kobj, &disk_attr_netif.attr);
> -	sysfs_create_file(&d->gd->kobj, &disk_attr_fwver.attr);
> +	int err;
> +
> +	err = sysfs_create_file(&d->gd->kobj, &disk_attr_state.attr);
> +	if (err)
> +		return err;
> +
> +	err = sysfs_create_file(&d->gd->kobj, &disk_attr_mac.attr);
> +	if (err)
> +		goto err_out_state;
> +
> +	err = sysfs_create_file(&d->gd->kobj, &disk_attr_netif.attr);
> +	if (err)
> +		goto err_out_mac;
> +
> +	err = sysfs_create_file(&d->gd->kobj, &disk_attr_fwver.attr);
> +	if (err)
> +		goto err_out_netif;

Oh, and in the future, it's easier to use an attribute group for this
kind of thing than backing out each and every attribute that is added.
The function to add all files in the attribute group properly tears
things down if there is an error along the way.

thanks,

greg k-h
-
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