diff options
| author | Kristian Høgsberg <krh@redhat.com> | 2007-07-02 17:52:07 -0400 | 
|---|---|---|
| committer | Kristian Høgsberg <krh@redhat.com> | 2007-07-02 17:52:07 -0400 | 
| commit | c9d752ff4fb2b6eee2fef636193fc9ca29abba37 (patch) | |
| tree | e692099487ffd04a0c4b3e9c7e448110444f2eef /linux-core/drm_sysfs.c | |
| parent | b323ab52aa9ccbfb06dd723ece361a5242d067b0 (diff) | |
Fix must-check warnings and implement a few error paths.
Diffstat (limited to 'linux-core/drm_sysfs.c')
| -rw-r--r-- | linux-core/drm_sysfs.c | 31 | 
1 files changed, 25 insertions, 6 deletions
diff --git a/linux-core/drm_sysfs.c b/linux-core/drm_sysfs.c index ace0778b..9b2f5dce 100644 --- a/linux-core/drm_sysfs.c +++ b/linux-core/drm_sysfs.c @@ -93,11 +93,15 @@ struct drm_sysfs_class *drm_sysfs_create(struct module *owner, char *name)  	retval = class_register(&cs->class);  	if (retval)  		goto error; -	class_create_file(&cs->class, &class_attr_version); +	retval = class_create_file(&cs->class, &class_attr_version); +	if (retval) +		goto error_with_class;  	return cs; -      error: + error_with_class: +	class_unregister(&cs->class); + error:  	kfree(cs);  	return ERR_PTR(retval);  } @@ -170,16 +174,31 @@ struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs,  	if (retval)  		goto error; -	class_device_create_file(&s_dev->class_dev, &cs->attr); +	retval = class_device_create_file(&s_dev->class_dev, &cs->attr); +	if (retval) +		goto error_with_device; +  	class_set_devdata(&s_dev->class_dev, head); -	for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) -		class_device_create_file(&s_dev->class_dev, &class_device_attrs[i]); +	for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) { +		retval = class_device_create_file(&s_dev->class_dev, +						  &class_device_attrs[i]); +		if (retval) +			goto error_with_files; +	}  	return &s_dev->class_dev; -error: + error_with_files: +	while (i > 0) +		class_device_remove_file(&s_dev->class_dev, +					 &class_device_attrs[--i]); +	class_device_remove_file(&s_dev->class_dev, &cs->attr); + error_with_device: +	class_device_unregister(&s_dev->class_dev); + error:  	kfree(s_dev); +  	return ERR_PTR(retval);  }  | 
