[S390] cio: Correct cleanup on error.
Fix cleanup on error in chp_new() and init_channel_subsystem() (must not call kfree() on structures that had been registered). Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
3d6e48f433
commit
a2164b8174
|
@ -423,7 +423,7 @@ int chp_new(struct chp_id chpid)
|
||||||
ret = sysfs_create_group(&chp->dev.kobj, &chp_attr_group);
|
ret = sysfs_create_group(&chp->dev.kobj, &chp_attr_group);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
device_unregister(&chp->dev);
|
device_unregister(&chp->dev);
|
||||||
goto out_free;
|
goto out;
|
||||||
}
|
}
|
||||||
mutex_lock(&channel_subsystems[chpid.cssid]->mutex);
|
mutex_lock(&channel_subsystems[chpid.cssid]->mutex);
|
||||||
if (channel_subsystems[chpid.cssid]->cm_enabled) {
|
if (channel_subsystems[chpid.cssid]->cm_enabled) {
|
||||||
|
@ -432,14 +432,15 @@ int chp_new(struct chp_id chpid)
|
||||||
sysfs_remove_group(&chp->dev.kobj, &chp_attr_group);
|
sysfs_remove_group(&chp->dev.kobj, &chp_attr_group);
|
||||||
device_unregister(&chp->dev);
|
device_unregister(&chp->dev);
|
||||||
mutex_unlock(&channel_subsystems[chpid.cssid]->mutex);
|
mutex_unlock(&channel_subsystems[chpid.cssid]->mutex);
|
||||||
goto out_free;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
channel_subsystems[chpid.cssid]->chps[chpid.id] = chp;
|
channel_subsystems[chpid.cssid]->chps[chpid.id] = chp;
|
||||||
mutex_unlock(&channel_subsystems[chpid.cssid]->mutex);
|
mutex_unlock(&channel_subsystems[chpid.cssid]->mutex);
|
||||||
return ret;
|
goto out;
|
||||||
out_free:
|
out_free:
|
||||||
kfree(chp);
|
kfree(chp);
|
||||||
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -633,6 +633,11 @@ channel_subsystem_release(struct device *dev)
|
||||||
|
|
||||||
css = to_css(dev);
|
css = to_css(dev);
|
||||||
mutex_destroy(&css->mutex);
|
mutex_destroy(&css->mutex);
|
||||||
|
if (css->pseudo_subchannel) {
|
||||||
|
/* Implies that it has been generated but never registered. */
|
||||||
|
css_subchannel_release(&css->pseudo_subchannel->dev);
|
||||||
|
css->pseudo_subchannel = NULL;
|
||||||
|
}
|
||||||
kfree(css);
|
kfree(css);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,11 +790,15 @@ init_channel_subsystem (void)
|
||||||
}
|
}
|
||||||
channel_subsystems[i] = css;
|
channel_subsystems[i] = css;
|
||||||
ret = setup_css(i);
|
ret = setup_css(i);
|
||||||
if (ret)
|
if (ret) {
|
||||||
goto out_free;
|
kfree(channel_subsystems[i]);
|
||||||
|
goto out_unregister;
|
||||||
|
}
|
||||||
ret = device_register(&css->device);
|
ret = device_register(&css->device);
|
||||||
if (ret)
|
if (ret) {
|
||||||
goto out_free_all;
|
put_device(&css->device);
|
||||||
|
goto out_unregister;
|
||||||
|
}
|
||||||
if (css_chsc_characteristics.secm) {
|
if (css_chsc_characteristics.secm) {
|
||||||
ret = device_create_file(&css->device,
|
ret = device_create_file(&css->device,
|
||||||
&dev_attr_cm_enable);
|
&dev_attr_cm_enable);
|
||||||
|
@ -802,7 +811,7 @@ init_channel_subsystem (void)
|
||||||
}
|
}
|
||||||
ret = register_reboot_notifier(&css_reboot_notifier);
|
ret = register_reboot_notifier(&css_reboot_notifier);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_pseudo;
|
goto out_unregister;
|
||||||
css_init_done = 1;
|
css_init_done = 1;
|
||||||
|
|
||||||
/* Enable default isc for I/O subchannels. */
|
/* Enable default isc for I/O subchannels. */
|
||||||
|
@ -810,18 +819,12 @@ init_channel_subsystem (void)
|
||||||
|
|
||||||
for_each_subchannel(__init_channel_subsystem, NULL);
|
for_each_subchannel(__init_channel_subsystem, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
out_pseudo:
|
|
||||||
device_unregister(&channel_subsystems[i]->pseudo_subchannel->dev);
|
|
||||||
out_file:
|
out_file:
|
||||||
device_remove_file(&channel_subsystems[i]->device,
|
if (css_chsc_characteristics.secm)
|
||||||
&dev_attr_cm_enable);
|
device_remove_file(&channel_subsystems[i]->device,
|
||||||
|
&dev_attr_cm_enable);
|
||||||
out_device:
|
out_device:
|
||||||
device_unregister(&channel_subsystems[i]->device);
|
device_unregister(&channel_subsystems[i]->device);
|
||||||
out_free_all:
|
|
||||||
kfree(channel_subsystems[i]->pseudo_subchannel->lock);
|
|
||||||
kfree(channel_subsystems[i]->pseudo_subchannel);
|
|
||||||
out_free:
|
|
||||||
kfree(channel_subsystems[i]);
|
|
||||||
out_unregister:
|
out_unregister:
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
struct channel_subsystem *css;
|
struct channel_subsystem *css;
|
||||||
|
@ -829,6 +832,7 @@ out_unregister:
|
||||||
i--;
|
i--;
|
||||||
css = channel_subsystems[i];
|
css = channel_subsystems[i];
|
||||||
device_unregister(&css->pseudo_subchannel->dev);
|
device_unregister(&css->pseudo_subchannel->dev);
|
||||||
|
css->pseudo_subchannel = NULL;
|
||||||
if (css_chsc_characteristics.secm)
|
if (css_chsc_characteristics.secm)
|
||||||
device_remove_file(&css->device,
|
device_remove_file(&css->device,
|
||||||
&dev_attr_cm_enable);
|
&dev_attr_cm_enable);
|
||||||
|
|
Loading…
Reference in New Issue