[Cbe-oss-dev] [PATCH 08/21] cell: catch errors from sysfs_create_group()

Christian Krafft krafft at de.ibm.com
Wed Dec 5 20:22:35 EST 2007


Hi Jeremy,

Thanks for that one. I owe you a beer at least.

ck

On Wed, 05 Dec 2007 13:49:31 +1100
Jeremy Kerr <jk at ozlabs.org> wrote:

> We're currently getting a warning from not checking the result of
> sysfs_create_group, which is declared as __must_check.
> 
> This change introduces appropriate error-handling for
> spu_add_sysdev_attr_group()
> 
> Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
> 
> ---
>  arch/powerpc/platforms/cell/spu_base.c |   20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/cell/spu_base.c
> b/arch/powerpc/platforms/cell/spu_base.c index ee37e0e..f73263b 100644
> --- a/arch/powerpc/platforms/cell/spu_base.c
> +++ b/arch/powerpc/platforms/cell/spu_base.c
> @@ -574,13 +574,27 @@ EXPORT_SYMBOL_GPL(spu_add_sysdev_attr);
>  int spu_add_sysdev_attr_group(struct attribute_group *attrs)
>  {
>  	struct spu *spu;
> +	int rc = 0;
> 
>  	mutex_lock(&spu_full_list_mutex);
> -	list_for_each_entry(spu, &spu_full_list, full_list)
> -		sysfs_create_group(&spu->sysdev.kobj, attrs);
> +	list_for_each_entry(spu, &spu_full_list, full_list) {
> +		rc = sysfs_create_group(&spu->sysdev.kobj, attrs);
> +
> +		/* we're in trouble here, but try unwinding anyway */
> +		if (rc) {
> +			printk(KERN_ERR "%s: can't create sysfs group
> '%s'\n",
> +					__func__, attrs->name);
> +
> +			list_for_each_entry_continue_reverse(spu,
> +					&spu_full_list, full_list)
> +				sysfs_remove_group(&spu->sysdev.kobj, attrs);
> +			break;
> +		}
> +	}
> +
>  	mutex_unlock(&spu_full_list_mutex);
> 
> -	return 0;
> +	return rc;
>  }
>  EXPORT_SYMBOL_GPL(spu_add_sysdev_attr_group);
> 
> _______________________________________________
> cbe-oss-dev mailing list
> cbe-oss-dev at ozlabs.org
> https://ozlabs.org/mailman/listinfo/cbe-oss-dev


-- 
Mit freundlichen Gruessen,
kind regards,

Christian Krafft
IBM Systems & Technology Group,
Linux Kernel Development
IT Specialist


Vorsitzender des Aufsichtsrats:	Martin Jetter
Geschaeftsfuehrung:		Herbert Kircher
Sitz der Gesellschaft:		Boeblingen
Registriergericht:		Amtsgericht Stuttgart, HRB 243294
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/cbe-oss-dev/attachments/20071205/6b7080a4/attachment.pgp>


More information about the cbe-oss-dev mailing list