Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kho: fix missing early_memunmap() call in kho_populate()

Patch series "two fixes in kho_populate()", v3.


This patch (of 2):

kho_populate() returns without calling early_memunmap() on success path,
this will cause early ioremap virtual address space leak.

Link: https://lkml.kernel.org/r/20260212111146.210086-1-ranxiaokai627@163.com
Link: https://lkml.kernel.org/r/20260212111146.210086-2-ranxiaokai627@163.com
Fixes: b50634c5e84a ("kho: cleanup error handling in kho_populate()")
Signed-off-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
Cc: Alexander Graf <graf@amazon.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Ran Xiaokai and committed by
Andrew Morton
34df6c47 55f8b451

+14 -12
+14 -12
kernel/liveupdate/kexec_handover.c
··· 1463 1463 struct kho_scratch *scratch = NULL; 1464 1464 phys_addr_t mem_map_phys; 1465 1465 void *fdt = NULL; 1466 + bool populated = false; 1466 1467 int err; 1467 1468 1468 1469 /* Validate the input FDT */ 1469 1470 fdt = early_memremap(fdt_phys, fdt_len); 1470 1471 if (!fdt) { 1471 1472 pr_warn("setup: failed to memremap FDT (0x%llx)\n", fdt_phys); 1472 - goto err_report; 1473 + goto report; 1473 1474 } 1474 1475 err = fdt_check_header(fdt); 1475 1476 if (err) { 1476 1477 pr_warn("setup: handover FDT (0x%llx) is invalid: %d\n", 1477 1478 fdt_phys, err); 1478 - goto err_unmap_fdt; 1479 + goto unmap_fdt; 1479 1480 } 1480 1481 err = fdt_node_check_compatible(fdt, 0, KHO_FDT_COMPATIBLE); 1481 1482 if (err) { 1482 1483 pr_warn("setup: handover FDT (0x%llx) is incompatible with '%s': %d\n", 1483 1484 fdt_phys, KHO_FDT_COMPATIBLE, err); 1484 - goto err_unmap_fdt; 1485 + goto unmap_fdt; 1485 1486 } 1486 1487 1487 1488 mem_map_phys = kho_get_mem_map_phys(fdt); 1488 1489 if (!mem_map_phys) 1489 - goto err_unmap_fdt; 1490 + goto unmap_fdt; 1490 1491 1491 1492 scratch = early_memremap(scratch_phys, scratch_len); 1492 1493 if (!scratch) { 1493 1494 pr_warn("setup: failed to memremap scratch (phys=0x%llx, len=%lld)\n", 1494 1495 scratch_phys, scratch_len); 1495 - goto err_unmap_fdt; 1496 + goto unmap_fdt; 1496 1497 } 1497 1498 1498 1499 /* ··· 1510 1509 if (WARN_ON(err)) { 1511 1510 pr_warn("failed to mark the scratch region 0x%pa+0x%pa: %pe", 1512 1511 &area->addr, &size, ERR_PTR(err)); 1513 - goto err_unmap_scratch; 1512 + goto unmap_scratch; 1514 1513 } 1515 1514 pr_debug("Marked 0x%pa+0x%pa as scratch", &area->addr, &size); 1516 1515 } ··· 1530 1529 kho_in.scratch_phys = scratch_phys; 1531 1530 kho_in.mem_map_phys = mem_map_phys; 1532 1531 kho_scratch_cnt = scratch_cnt; 1532 + 1533 + populated = true; 1533 1534 pr_info("found kexec handover data.\n"); 1534 1535 1535 - return; 1536 - 1537 - err_unmap_scratch: 1536 + unmap_scratch: 1538 1537 early_memunmap(scratch, scratch_len); 1539 - err_unmap_fdt: 1538 + unmap_fdt: 1540 1539 early_memunmap(fdt, fdt_len); 1541 - err_report: 1542 - pr_warn("disabling KHO revival\n"); 1540 + report: 1541 + if (!populated) 1542 + pr_warn("disabling KHO revival\n"); 1543 1543 } 1544 1544 1545 1545 /* Helper functions for kexec_file_load */