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: cleanup error handling in kho_populate()

* use dedicated labels for error handling instead of checking if a pointer
is not null to decide if it should be unmapped
* drop assignment of values to err that are only used to print a numeric
error code, there are pr_warn()s for each failure already so printing a
numeric error code in the next line does not add anything useful

Link: https://lkml.kernel.org/r/20260122121757.575987-1-rppt@kernel.org
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
Cc: Alexander Graf <graf@amazon.com>
Cc: Mike Rapoport <rppt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Mike Rapoport (Microsoft) and committed by
Andrew Morton
b50634c5 0895a000

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