Commit 7faefea6 authored by Yinghai Lu's avatar Yinghai Lu Committed by Linus Torvalds

ipmi: fix memleaking for add_smi when duplicating happen

Free the temporary info struct when we have duplicated ones.
Signed-off-by: default avatarYinghai Lu <yinghai@kernel.org>
Cc: Corey Minyard <minyard@acm.org>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Myron Stowe <myron.stowe@hp.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f46c77c2
...@@ -1804,9 +1804,12 @@ static int hotmod_handler(const char *val, struct kernel_param *kp) ...@@ -1804,9 +1804,12 @@ static int hotmod_handler(const char *val, struct kernel_param *kp)
info->irq_setup = std_irq_setup; info->irq_setup = std_irq_setup;
info->slave_addr = ipmb; info->slave_addr = ipmb;
if (!add_smi(info)) if (!add_smi(info)) {
if (try_smi_init(info)) if (try_smi_init(info))
cleanup_one_si(info); cleanup_one_si(info);
} else {
kfree(info);
}
} else { } else {
/* remove */ /* remove */
struct smi_info *e, *tmp_e; struct smi_info *e, *tmp_e;
...@@ -1890,9 +1893,12 @@ static __devinit void hardcode_find_bmc(void) ...@@ -1890,9 +1893,12 @@ static __devinit void hardcode_find_bmc(void)
info->irq_setup = std_irq_setup; info->irq_setup = std_irq_setup;
info->slave_addr = slave_addrs[i]; info->slave_addr = slave_addrs[i];
if (!add_smi(info)) if (!add_smi(info)) {
if (try_smi_init(info)) if (try_smi_init(info))
cleanup_one_si(info); cleanup_one_si(info);
} else {
kfree(info);
}
} }
} }
...@@ -2082,7 +2088,8 @@ static __devinit int try_init_spmi(struct SPMITable *spmi) ...@@ -2082,7 +2088,8 @@ static __devinit int try_init_spmi(struct SPMITable *spmi)
} }
info->io.addr_data = spmi->addr.address; info->io.addr_data = spmi->addr.address;
add_smi(info); if (add_smi(info))
kfree(info);
return 0; return 0;
} }
...@@ -2198,7 +2205,10 @@ static int __devinit ipmi_pnp_probe(struct pnp_dev *dev, ...@@ -2198,7 +2205,10 @@ static int __devinit ipmi_pnp_probe(struct pnp_dev *dev,
res, info->io.regsize, info->io.regspacing, res, info->io.regsize, info->io.regspacing,
info->irq); info->irq);
return add_smi(info); if (add_smi(info))
goto err_free;
return 0;
err_free: err_free:
kfree(info); kfree(info);
...@@ -2356,7 +2366,8 @@ static __devinit void try_init_dmi(struct dmi_ipmi_data *ipmi_data) ...@@ -2356,7 +2366,8 @@ static __devinit void try_init_dmi(struct dmi_ipmi_data *ipmi_data)
if (info->irq) if (info->irq)
info->irq_setup = std_irq_setup; info->irq_setup = std_irq_setup;
add_smi(info); if (add_smi(info))
kfree(info);
} }
static void __devinit dmi_find_bmc(void) static void __devinit dmi_find_bmc(void)
...@@ -2462,7 +2473,10 @@ static int __devinit ipmi_pci_probe(struct pci_dev *pdev, ...@@ -2462,7 +2473,10 @@ static int __devinit ipmi_pci_probe(struct pci_dev *pdev,
&pdev->resource[0], info->io.regsize, info->io.regspacing, &pdev->resource[0], info->io.regsize, info->io.regspacing,
info->irq); info->irq);
return add_smi(info); if (add_smi(info))
kfree(info);
return 0;
} }
static void __devexit ipmi_pci_remove(struct pci_dev *pdev) static void __devexit ipmi_pci_remove(struct pci_dev *pdev)
...@@ -2575,7 +2589,12 @@ static int __devinit ipmi_of_probe(struct of_device *dev, ...@@ -2575,7 +2589,12 @@ static int __devinit ipmi_of_probe(struct of_device *dev,
dev_set_drvdata(&dev->dev, info); dev_set_drvdata(&dev->dev, info);
return add_smi(info); if (add_smi(info)) {
kfree(info);
return -EBUSY;
}
return 0;
} }
static int __devexit ipmi_of_remove(struct of_device *dev) static int __devexit ipmi_of_remove(struct of_device *dev)
...@@ -3008,6 +3027,8 @@ static __devinit void default_find_bmc(void) ...@@ -3008,6 +3027,8 @@ static __devinit void default_find_bmc(void)
info->io.addr_data); info->io.addr_data);
} else } else
cleanup_one_si(info); cleanup_one_si(info);
} else {
kfree(info);
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment