public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Driver core: Fix device_add_attrs() error code path
@ 2013-12-12  5:11 Rafael J. Wysocki
  2013-12-12 15:27 ` Toshi Kani
  2013-12-12 23:13 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2013-12-12  5:11 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: LKML, Toshi Kani

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

If the addition of dev_attr_online fails, device_add_attrs() should
remove device attribute groups as well as type and class attribute
groups before returning an error code.  Make that happen.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/base/core.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: linux-pm/drivers/base/core.c
===================================================================
--- linux-pm.orig/drivers/base/core.c
+++ linux-pm/drivers/base/core.c
@@ -491,11 +491,13 @@ static int device_add_attrs(struct devic
 	if (device_supports_offline(dev) && !dev->offline_disabled) {
 		error = device_create_file(dev, &dev_attr_online);
 		if (error)
-			goto err_remove_type_groups;
+			goto err_remove_dev_groups;
 	}
 
 	return 0;
 
+ err_remove_dev_groups:
+ 	device_remove_groups(dev, dev->groups);
  err_remove_type_groups:
 	if (type)
 		device_remove_groups(dev, type->groups);


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-13  4:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-12  5:11 [PATCH] Driver core: Fix device_add_attrs() error code path Rafael J. Wysocki
2013-12-12 15:27 ` Toshi Kani
2013-12-12 23:13 ` Greg Kroah-Hartman
2013-12-13  5:00   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox