diff --git a/drivers/base/transport_class.c b/drivers/base/transport_class.c index 5ed86ded6e6b61a813acbd876e814c6f43607fe7..4c75dce605515f8e892b69ce3b195d0d1c699dca 100644 --- a/drivers/base/transport_class.c +++ b/drivers/base/transport_class.c @@ -151,12 +151,27 @@ static int transport_add_class_device(struct attribute_container *cont, struct device *dev, struct device *classdev) { + struct transport_class *tclass = class_to_transport_class(cont->class); int error = attribute_container_add_class_device(classdev); struct transport_container *tcont = attribute_container_to_transport_container(cont); - if (!error && tcont->statistics) + if (error) + goto err_remove; + + if (tcont->statistics) { error = sysfs_create_group(&classdev->kobj, tcont->statistics); + if (error) + goto err_del; + } + + return 0; + +err_del: + attribute_container_class_device_del(classdev); +err_remove: + if (tclass->remove) + tclass->remove(tcont, dev, classdev); return error; }