Commit 16f7f956 authored by Peter Oberparleiter's avatar Peter Oberparleiter Committed by Martin Schwidefsky

[S390] cio: fix ccw group device cleanup

Fix ccw group device initialization: initialize device object before
using reference counting during cleanup.

Fixes the following message when group device initialization fails
(e.g. because too few devices where specified):

  kobject: '<NULL>' (..): is not initialized, yet kobject_put() is
           being called.
Signed-off-by: default avatarPeter Oberparleiter <peter.oberparleiter@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 0686e402
...@@ -112,9 +112,11 @@ ccwgroup_release (struct device *dev) ...@@ -112,9 +112,11 @@ ccwgroup_release (struct device *dev)
gdev = to_ccwgroupdev(dev); gdev = to_ccwgroupdev(dev);
for (i = 0; i < gdev->count; i++) { for (i = 0; i < gdev->count; i++) {
if (gdev->cdev[i]) {
dev_set_drvdata(&gdev->cdev[i]->dev, NULL); dev_set_drvdata(&gdev->cdev[i]->dev, NULL);
put_device(&gdev->cdev[i]->dev); put_device(&gdev->cdev[i]->dev);
} }
}
kfree(gdev); kfree(gdev);
} }
...@@ -221,6 +223,13 @@ int ccwgroup_create_from_string(struct device *root, unsigned int creator_id, ...@@ -221,6 +223,13 @@ int ccwgroup_create_from_string(struct device *root, unsigned int creator_id,
atomic_set(&gdev->onoff, 0); atomic_set(&gdev->onoff, 0);
mutex_init(&gdev->reg_mutex); mutex_init(&gdev->reg_mutex);
mutex_lock(&gdev->reg_mutex); mutex_lock(&gdev->reg_mutex);
gdev->creator_id = creator_id;
gdev->count = num_devices;
gdev->dev.bus = &ccwgroup_bus_type;
gdev->dev.parent = root;
gdev->dev.release = ccwgroup_release;
device_initialize(&gdev->dev);
curr_buf = buf; curr_buf = buf;
for (i = 0; i < num_devices && curr_buf; i++) { for (i = 0; i < num_devices && curr_buf; i++) {
rc = __get_next_bus_id(&curr_buf, tmp_bus_id); rc = __get_next_bus_id(&curr_buf, tmp_bus_id);
...@@ -258,16 +267,11 @@ int ccwgroup_create_from_string(struct device *root, unsigned int creator_id, ...@@ -258,16 +267,11 @@ int ccwgroup_create_from_string(struct device *root, unsigned int creator_id,
rc = -EINVAL; rc = -EINVAL;
goto error; goto error;
} }
gdev->creator_id = creator_id;
gdev->count = num_devices;
gdev->dev.bus = &ccwgroup_bus_type;
gdev->dev.parent = root;
gdev->dev.release = ccwgroup_release;
snprintf (gdev->dev.bus_id, BUS_ID_SIZE, "%s", snprintf (gdev->dev.bus_id, BUS_ID_SIZE, "%s",
gdev->cdev[0]->dev.bus_id); gdev->cdev[0]->dev.bus_id);
rc = device_register(&gdev->dev); rc = device_add(&gdev->dev);
if (rc) if (rc)
goto error; goto error;
get_device(&gdev->dev); get_device(&gdev->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment