Skip to content

Commit

Permalink
ipmi_si: Fix error handling of platform device
Browse files Browse the repository at this point in the history
Cleanup of platform devices created by the IPMI driver was not
being done correctly and could result in a memory leak.  So
create a local boolean to know how to clean up those platform
devices.

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
  • Loading branch information
Corey Minyard committed Dec 12, 2017
1 parent 7195a5a commit 174134a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/char/ipmi/ipmi_si_intf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2045,6 +2045,7 @@ static int try_smi_init(struct smi_info *new_smi)
int rv = 0;
int i;
char *init_name = NULL;
bool platform_device_registered = false;

pr_info(PFX "Trying %s-specified %s state machine at %s address 0x%lx, slave address 0x%x, irq %d\n",
ipmi_addr_src_to_str(new_smi->io.addr_source),
Expand Down Expand Up @@ -2173,6 +2174,7 @@ static int try_smi_init(struct smi_info *new_smi)
rv);
goto out_err;
}
platform_device_registered = true;
}

dev_set_drvdata(new_smi->io.dev, new_smi);
Expand Down Expand Up @@ -2279,10 +2281,11 @@ static int try_smi_init(struct smi_info *new_smi)
}

if (new_smi->pdev) {
platform_device_unregister(new_smi->pdev);
if (platform_device_registered)
platform_device_unregister(new_smi->pdev);
else
platform_device_put(new_smi->pdev);
new_smi->pdev = NULL;
} else if (new_smi->pdev) {
platform_device_put(new_smi->pdev);
}

kfree(init_name);
Expand Down

0 comments on commit 174134a

Please sign in to comment.