Skip to content

Commit 20edec3

Browse files
bebarinogregkh
authored andcommitted
firmware: coreboot: Unmap ioregion after device population
Both callers of coreboot_table_init() ioremap the pointer that comes in but they don't unmap the memory on failure. Both of them also fail probe immediately with the return value of coreboot_table_init(), leaking a mapping when it fails. The mapping isn't necessary at all after devices are populated either, so we can just drop the mapping here when we exit the function. Let's do that to simplify the code a bit and plug the leak. Cc: Wei-Ning Huang <[email protected]> Cc: Julius Werner <[email protected]> Cc: Brian Norris <[email protected]> Cc: Samuel Holland <[email protected]> Fixes: 570d30c ("firmware: coreboot: Expose the coreboot table as a bus") Signed-off-by: Stephen Boyd <[email protected]> Reviewed-by: Julius Werner <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 09ed061 commit 20edec3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/firmware/google/coreboot_table.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ int coreboot_table_init(struct device *dev, void __iomem *ptr)
110110

111111
if (strncmp(header.signature, "LBIO", sizeof(header.signature))) {
112112
pr_warn("coreboot_table: coreboot table missing or corrupt!\n");
113-
return -ENODEV;
113+
ret = -ENODEV;
114+
goto out;
114115
}
115116

116117
ptr_entry = (void *)ptr_header + header.header_bytes;
@@ -137,7 +138,8 @@ int coreboot_table_init(struct device *dev, void __iomem *ptr)
137138

138139
ptr_entry += entry.size;
139140
}
140-
141+
out:
142+
iounmap(ptr);
141143
return ret;
142144
}
143145
EXPORT_SYMBOL(coreboot_table_init);
@@ -146,7 +148,6 @@ int coreboot_table_exit(void)
146148
{
147149
if (ptr_header) {
148150
bus_unregister(&coreboot_bus_type);
149-
iounmap(ptr_header);
150151
ptr_header = NULL;
151152
}
152153

0 commit comments

Comments
 (0)