summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNavid Emamdoost <navid.emamdoost@gmail.com>2019-10-21 15:06:48 -0500
committerCorey Minyard <cminyard@mvista.com>2019-10-22 14:42:34 -0500
commit4aa7afb0ee20a97fbf0c5bab3df028d5fb85fdab (patch)
tree4ca5468a11f43df1acec8a03e3f7e9eff0b2b59b /drivers
parent2a21d858f96bdfd3de28abc1341935d06fb47373 (diff)
downloadlinux-stable-4aa7afb0ee20a97fbf0c5bab3df028d5fb85fdab.tar.gz
linux-stable-4aa7afb0ee20a97fbf0c5bab3df028d5fb85fdab.tar.bz2
linux-stable-4aa7afb0ee20a97fbf0c5bab3df028d5fb85fdab.zip
ipmi: Fix memory leak in __ipmi_bmc_register
In the impelementation of __ipmi_bmc_register() the allocated memory for bmc should be released in case ida_simple_get() fails. Fixes: 68e7e50f195f ("ipmi: Don't use BMC product/dev ids in the BMC name") Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com> Message-Id: <20191021200649.1511-1-navid.emamdoost@gmail.com> Signed-off-by: Corey Minyard <cminyard@mvista.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 2bac299db201..cad9563f8f48 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -3020,8 +3020,11 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf,
bmc->pdev.name = "ipmi_bmc";
rv = ida_simple_get(&ipmi_bmc_ida, 0, 0, GFP_KERNEL);
- if (rv < 0)
+ if (rv < 0) {
+ kfree(bmc);
goto out;
+ }
+
bmc->pdev.dev.driver = &ipmidriver.driver;
bmc->pdev.id = rv;
bmc->pdev.dev.release = release_bmc_device;