aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/cio
diff options
context:
space:
mode:
authorCornelia Huck <cornelia.huck@de.ibm.com>2008-09-09 06:38:57 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2008-09-09 06:39:07 -0400
commita2164b8174f13b7315c3f45c0b48dec619285096 (patch)
treed3e943b5c8be1d999331879c002b9c26081c48fe /drivers/s390/cio
parent3d6e48f43340343d97839eadb1ab7b6a3ea98797 (diff)
[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>
Diffstat (limited to 'drivers/s390/cio')
-rw-r--r--drivers/s390/cio/chp.c7
-rw-r--r--drivers/s390/cio/css.c32
2 files changed, 22 insertions, 17 deletions
diff --git a/drivers/s390/cio/chp.c b/drivers/s390/cio/chp.c
index db00b0591733..f1216cf6fa8f 100644
--- a/drivers/s390/cio/chp.c
+++ b/drivers/s390/cio/chp.c
@@ -423,7 +423,7 @@ int chp_new(struct chp_id chpid)
423 ret = sysfs_create_group(&chp->dev.kobj, &chp_attr_group); 423 ret = sysfs_create_group(&chp->dev.kobj, &chp_attr_group);
424 if (ret) { 424 if (ret) {
425 device_unregister(&chp->dev); 425 device_unregister(&chp->dev);
426 goto out_free; 426 goto out;
427 } 427 }
428 mutex_lock(&channel_subsystems[chpid.cssid]->mutex); 428 mutex_lock(&channel_subsystems[chpid.cssid]->mutex);
429 if (channel_subsystems[chpid.cssid]->cm_enabled) { 429 if (channel_subsystems[chpid.cssid]->cm_enabled) {
@@ -432,14 +432,15 @@ int chp_new(struct chp_id chpid)
432 sysfs_remove_group(&chp->dev.kobj, &chp_attr_group); 432 sysfs_remove_group(&chp->dev.kobj, &chp_attr_group);
433 device_unregister(&chp->dev); 433 device_unregister(&chp->dev);
434 mutex_unlock(&channel_subsystems[chpid.cssid]->mutex); 434 mutex_unlock(&channel_subsystems[chpid.cssid]->mutex);
435 goto out_free; 435 goto out;
436 } 436 }
437 } 437 }
438 channel_subsystems[chpid.cssid]->chps[chpid.id] = chp; 438 channel_subsystems[chpid.cssid]->chps[chpid.id] = chp;
439 mutex_unlock(&channel_subsystems[chpid.cssid]->mutex); 439 mutex_unlock(&channel_subsystems[chpid.cssid]->mutex);
440 return ret; 440 goto out;
441out_free: 441out_free:
442 kfree(chp); 442 kfree(chp);
443out:
443 return ret; 444 return ret;
444} 445}
445 446
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 51489eff6b0b..1261e1a9e8cd 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -633,6 +633,11 @@ channel_subsystem_release(struct device *dev)
633 633
634 css = to_css(dev); 634 css = to_css(dev);
635 mutex_destroy(&css->mutex); 635 mutex_destroy(&css->mutex);
636 if (css->pseudo_subchannel) {
637 /* Implies that it has been generated but never registered. */
638 css_subchannel_release(&css->pseudo_subchannel->dev);
639 css->pseudo_subchannel = NULL;
640 }
636 kfree(css); 641 kfree(css);
637} 642}
638 643
@@ -785,11 +790,15 @@ init_channel_subsystem (void)
785 } 790 }
786 channel_subsystems[i] = css; 791 channel_subsystems[i] = css;
787 ret = setup_css(i); 792 ret = setup_css(i);
788 if (ret) 793 if (ret) {
789 goto out_free; 794 kfree(channel_subsystems[i]);
795 goto out_unregister;
796 }
790 ret = device_register(&css->device); 797 ret = device_register(&css->device);
791 if (ret) 798 if (ret) {
792 goto out_free_all; 799 put_device(&css->device);
800 goto out_unregister;
801 }
793 if (css_chsc_characteristics.secm) { 802 if (css_chsc_characteristics.secm) {
794 ret = device_create_file(&css->device, 803 ret = device_create_file(&css->device,
795 &dev_attr_cm_enable); 804 &dev_attr_cm_enable);
@@ -802,7 +811,7 @@ init_channel_subsystem (void)
802 } 811 }
803 ret = register_reboot_notifier(&css_reboot_notifier); 812 ret = register_reboot_notifier(&css_reboot_notifier);
804 if (ret) 813 if (ret)
805 goto out_pseudo; 814 goto out_unregister;
806 css_init_done = 1; 815 css_init_done = 1;
807 816
808 /* Enable default isc for I/O subchannels. */ 817 /* Enable default isc for I/O subchannels. */
@@ -810,18 +819,12 @@ init_channel_subsystem (void)
810 819
811 for_each_subchannel(__init_channel_subsystem, NULL); 820 for_each_subchannel(__init_channel_subsystem, NULL);
812 return 0; 821 return 0;
813out_pseudo:
814 device_unregister(&channel_subsystems[i]->pseudo_subchannel->dev);
815out_file: 822out_file:
816 device_remove_file(&channel_subsystems[i]->device, 823 if (css_chsc_characteristics.secm)
817 &dev_attr_cm_enable); 824 device_remove_file(&channel_subsystems[i]->device,
825 &dev_attr_cm_enable);
818out_device: 826out_device:
819 device_unregister(&channel_subsystems[i]->device); 827 device_unregister(&channel_subsystems[i]->device);
820out_free_all:
821 kfree(channel_subsystems[i]->pseudo_subchannel->lock);
822 kfree(channel_subsystems[i]->pseudo_subchannel);
823out_free:
824 kfree(channel_subsystems[i]);
825out_unregister: 828out_unregister:
826 while (i > 0) { 829 while (i > 0) {
827 struct channel_subsystem *css; 830 struct channel_subsystem *css;
@@ -829,6 +832,7 @@ out_unregister:
829 i--; 832 i--;
830 css = channel_subsystems[i]; 833 css = channel_subsystems[i];
831 device_unregister(&css->pseudo_subchannel->dev); 834 device_unregister(&css->pseudo_subchannel->dev);
835 css->pseudo_subchannel = NULL;
832 if (css_chsc_characteristics.secm) 836 if (css_chsc_characteristics.secm)
833 device_remove_file(&css->device, 837 device_remove_file(&css->device,
834 &dev_attr_cm_enable); 838 &dev_attr_cm_enable);