Commit ee91592711ed90a1abfbb1b2ceadded11d685164

Authored by Saul St. John
Committed by John W. Linville
1 parent 0374737727

bcma: don't leak memory for PCIE, MIPS, GBIT cores

bcma_scan_bus allocates a bcma_core for each core found on the bus, but the
memory for cores handled by the bcma driver itself was not being freed when
the bus was unregistered. This patch adds special handling for the PCIE,
MIPS, and GBIT COMMON cores, to ensure that their memory allocation is
freed as well.

Note that this patch doesn't address the memory allocated for the CC core,
as that was corrected in my previous patch "bcma: register cc core driver,
device."

Cc: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Saul St. John <saul.stjohn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

Showing 1 changed file with 10 additions and 0 deletions Side-by-side Diff

... ... @@ -227,7 +227,17 @@
227 227  
228 228 void bcma_bus_unregister(struct bcma_bus *bus)
229 229 {
  230 + struct bcma_device *cores[3];
  231 +
  232 + cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
  233 + cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE);
  234 + cores[2] = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
  235 +
230 236 bcma_unregister_cores(bus);
  237 +
  238 + kfree(cores[2]);
  239 + kfree(cores[1]);
  240 + kfree(cores[0]);
231 241 }
232 242  
233 243 int __init bcma_bus_early_register(struct bcma_bus *bus,