habanalabs: rephrase error messages in PCI initialization
PATCH 1/2 habanalabs: rephrase error messages in PCI initialization
The iATU is an internal h/w machine inside Habana's PCI controller. Mentioning it by name doesn't say anything to the user. It is better to say the PCI controller initialization was not done successfully.
Signed-off-by Oded Gabbay <[email protected]>
--- drivers/misc/habanalabs/common/pci/pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/habanalabs/common/pci/pci.c +2 -2
@@ -408,13 +408,13 @@ int hl_pci_init(struct hl_device *hdev) rc = hdev->asic_funcs->pci_bars_map (hdev);if (rc) { -dev_err (hdev->dev,"Failed to initialize PCI BARs\n" ); +dev_err (hdev->dev,"Failed to map PCI BAR addresses\n" ); goto disable_device; } rc = hdev->asic_funcs->init_iatu (hdev);if (rc) { -dev_err (hdev->dev,"Failed to initialize iATU\n" ); +dev_err (hdev->dev,"PCI controller was not initialized successfully\n" ); goto unmap_pci_bars; }
Signature · 1 line
2.25.1
PATCH 2/2 habanalabs: fix use-after-free bug
When the code iterates over the free list of physical pages nodes, it deletes the physical page node which is used as the iterator.
Therefore, we need to use the safe version of the iteration to prevent use-after-free.
Signed-off-by Oded Gabbay <[email protected]>
--- drivers/misc/habanalabs/common/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/habanalabs/common/memory.c +2 -2
@@ -2860,7 +2860,7 @@ int hl_vm_ctx_init(struct hl_ctx *ctx)*/ void hl_vm_ctx_fini (struct hl_ctx *ctx) { -struct hl_vm_phys_pg_pack *phys_pg_list; +struct hl_vm_phys_pg_pack *phys_pg_list, *tmp_phys_node;struct hl_device *hdev = ctx->hdev;struct hl_vm_hash_node *hnode;struct hl_vm *vm = &hdev->vm;
@@ -2913,7 +2913,7 @@ void hl_vm_ctx_fini(struct hl_ctx *ctx) }spin_unlock (&vm->idr_lock); -list_for_each_entry (phys_pg_list, &free_list, node) +list_for_each_entry_safe (phys_pg_list, tmp_phys_node, &free_list, node)free_phys_pg_pack (hdev, phys_pg_list);va_range_fini (hdev, ctx->va_range[HL_VA_RANGE_TYPE_DRAM ]);
Signature · 1 line
2.25.1