Skip to content

Commit b299738

Browse files
mkaehlckegregkh
authored andcommitted
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>
1 parent 2cf4e52 commit b299738

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

‎drivers/misc/ti-st/st_kim.c‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -705,9 +705,9 @@ static const struct file_operations list_debugfs_fops = {
705705
static struct dentry *kim_debugfs_dir;
706706
static int kim_probe(struct platform_device *pdev)
707707
{
708-
long status;
709708
struct kim_data_s *kim_gdata;
710709
struct ti_st_plat_data *pdata = pdev->dev.platform_data;
710+
int err;
711711

712712
if ((pdev->id != -1) && (pdev->id < MAX_ST_DEVICES)) {
713713
/* multiple devices could exist */
@@ -724,10 +724,11 @@ static int kim_probe(struct platform_device *pdev)
724724
}
725725
dev_set_drvdata(&pdev->dev, kim_gdata);
726726

727-
status = st_core_init(&kim_gdata->core_data);
728-
if (status != 0) {
727+
err = st_core_init(&kim_gdata->core_data);
728+
if (err != 0) {
729729
pr_err(" ST core init failed");
730-
return -EIO;
730+
err = -EIO;
731+
goto err_core_init;
731732
}
732733
/* refer to itself */
733734
kim_gdata->core_data->kim_data = kim_gdata;
@@ -738,10 +739,10 @@ static int kim_probe(struct platform_device *pdev)
738739
init_completion(&kim_gdata->kim_rcvd);
739740
init_completion(&kim_gdata->ldisc_installed);
740741

741-
status = sysfs_create_group(&pdev->dev.kobj, &uim_attr_grp);
742-
if (status) {
742+
err = sysfs_create_group(&pdev->dev.kobj, &uim_attr_grp);
743+
if (err) {
743744
pr_err("failed to create sysfs entries");
744-
return status;
745+
goto err_sysfs_group;
745746
}
746747

747748
/* copying platform data */
@@ -753,8 +754,8 @@ static int kim_probe(struct platform_device *pdev)
753754
kim_debugfs_dir = debugfs_create_dir("ti-st", NULL);
754755
if (IS_ERR(kim_debugfs_dir)) {
755756
pr_err(" debugfs entries creation failed ");
756-
kim_debugfs_dir = NULL;
757-
return -EIO;
757+
err = -EIO;
758+
goto err_debugfs_dir;
758759
}
759760

760761
debugfs_create_file("version", S_IRUGO, kim_debugfs_dir,
@@ -763,6 +764,17 @@ static int kim_probe(struct platform_device *pdev)
763764
kim_gdata, &list_debugfs_fops);
764765
pr_info(" debugfs entries created ");
765766
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;
766778
}
767779

768780
static int kim_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)