diff options
author | Matthias Kaehlcke <matthias@kaehlcke.net> | 2012-11-22 17:26:14 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-11-26 19:16:35 -0500 |
commit | b2997387c291ecf8015a89fc626f02be60e359a0 (patch) | |
tree | b9b9ce7796389fb3d3db5a9c839f01e438aab79b /drivers/misc | |
parent | 2cf4e52e27dc719941cd3727205ca62b742f2746 (diff) |
misc/st_kim: Free resources in the error path of probe()
Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/ti-st/st_kim.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c index 04a819944f6b..9ff942a346ed 100644 --- a/drivers/misc/ti-st/st_kim.c +++ b/drivers/misc/ti-st/st_kim.c | |||
@@ -705,9 +705,9 @@ static const struct file_operations list_debugfs_fops = { | |||
705 | static struct dentry *kim_debugfs_dir; | 705 | static struct dentry *kim_debugfs_dir; |
706 | static int kim_probe(struct platform_device *pdev) | 706 | static int kim_probe(struct platform_device *pdev) |
707 | { | 707 | { |
708 | long status; | ||
709 | struct kim_data_s *kim_gdata; | 708 | struct kim_data_s *kim_gdata; |
710 | struct ti_st_plat_data *pdata = pdev->dev.platform_data; | 709 | struct ti_st_plat_data *pdata = pdev->dev.platform_data; |
710 | int err; | ||
711 | 711 | ||
712 | if ((pdev->id != -1) && (pdev->id < MAX_ST_DEVICES)) { | 712 | if ((pdev->id != -1) && (pdev->id < MAX_ST_DEVICES)) { |
713 | /* multiple devices could exist */ | 713 | /* multiple devices could exist */ |
@@ -724,10 +724,11 @@ static int kim_probe(struct platform_device *pdev) | |||
724 | } | 724 | } |
725 | dev_set_drvdata(&pdev->dev, kim_gdata); | 725 | dev_set_drvdata(&pdev->dev, kim_gdata); |
726 | 726 | ||
727 | status = st_core_init(&kim_gdata->core_data); | 727 | err = st_core_init(&kim_gdata->core_data); |
728 | if (status != 0) { | 728 | if (err != 0) { |
729 | pr_err(" ST core init failed"); | 729 | pr_err(" ST core init failed"); |
730 | return -EIO; | 730 | err = -EIO; |
731 | goto err_core_init; | ||
731 | } | 732 | } |
732 | /* refer to itself */ | 733 | /* refer to itself */ |
733 | kim_gdata->core_data->kim_data = kim_gdata; | 734 | kim_gdata->core_data->kim_data = kim_gdata; |
@@ -738,10 +739,10 @@ static int kim_probe(struct platform_device *pdev) | |||
738 | init_completion(&kim_gdata->kim_rcvd); | 739 | init_completion(&kim_gdata->kim_rcvd); |
739 | init_completion(&kim_gdata->ldisc_installed); | 740 | init_completion(&kim_gdata->ldisc_installed); |
740 | 741 | ||
741 | status = sysfs_create_group(&pdev->dev.kobj, &uim_attr_grp); | 742 | err = sysfs_create_group(&pdev->dev.kobj, &uim_attr_grp); |
742 | if (status) { | 743 | if (err) { |
743 | pr_err("failed to create sysfs entries"); | 744 | pr_err("failed to create sysfs entries"); |
744 | return status; | 745 | goto err_sysfs_group; |
745 | } | 746 | } |
746 | 747 | ||
747 | /* copying platform data */ | 748 | /* copying platform data */ |
@@ -753,8 +754,8 @@ static int kim_probe(struct platform_device *pdev) | |||
753 | kim_debugfs_dir = debugfs_create_dir("ti-st", NULL); | 754 | kim_debugfs_dir = debugfs_create_dir("ti-st", NULL); |
754 | if (IS_ERR(kim_debugfs_dir)) { | 755 | if (IS_ERR(kim_debugfs_dir)) { |
755 | pr_err(" debugfs entries creation failed "); | 756 | pr_err(" debugfs entries creation failed "); |
756 | kim_debugfs_dir = NULL; | 757 | err = -EIO; |
757 | return -EIO; | 758 | goto err_debugfs_dir; |
758 | } | 759 | } |
759 | 760 | ||
760 | debugfs_create_file("version", S_IRUGO, kim_debugfs_dir, | 761 | debugfs_create_file("version", S_IRUGO, kim_debugfs_dir, |
@@ -763,6 +764,17 @@ static int kim_probe(struct platform_device *pdev) | |||
763 | kim_gdata, &list_debugfs_fops); | 764 | kim_gdata, &list_debugfs_fops); |
764 | pr_info(" debugfs entries created "); | 765 | pr_info(" debugfs entries created "); |
765 | return 0; | 766 | return 0; |
767 | |||
768 | err_debugfs_dir: | ||
769 | sysfs_remove_group(&pdev->dev.kobj, &uim_attr_grp); | ||
770 | |||
771 | err_sysfs_group: | ||
772 | st_core_exit(kim_gdata->core_data); | ||
773 | |||
774 | err_core_init: | ||
775 | kfree(kim_gdata); | ||
776 | |||
777 | return err; | ||
766 | } | 778 | } |
767 | 779 | ||
768 | static int kim_remove(struct platform_device *pdev) | 780 | static int kim_remove(struct platform_device *pdev) |