[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250605115958.799831-1-l1138897701@163.com>
Date: Thu, 5 Jun 2025 19:59:58 +0800
From: luoqing <l1138897701@....com>
To: obitton@...ana.ai,
peterz@...radead.org
Cc: ogabbay@...nel.org,
dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org,
luoqing@...inos.cn
Subject: [PATCH 1/2] accel/habanalabs: ZERO_OR_NULL_PTR Macro overdetection
From: luoqing <luoqing@...inos.cn>
sizeof(xx) these variable values' return values cannot be 0.
For memory allocation requests of non-zero length,
there is no need to check other return values;
it is sufficient to only verify that it is not null.
Signed-off-by: luoqing <luoqing@...inos.cn>
---
drivers/accel/habanalabs/common/memory.c | 4 ++--
drivers/accel/habanalabs/common/mmu/mmu.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/accel/habanalabs/common/memory.c b/drivers/accel/habanalabs/common/memory.c
index 601fdbe70179..0d2782529ec3 100644
--- a/drivers/accel/habanalabs/common/memory.c
+++ b/drivers/accel/habanalabs/common/memory.c
@@ -140,7 +140,7 @@ static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args,
phys_pg_pack->contiguous = contiguous;
phys_pg_pack->pages = kvmalloc_array(num_pgs, sizeof(u64), GFP_KERNEL);
- if (ZERO_OR_NULL_PTR(phys_pg_pack->pages)) {
+ if (!(phys_pg_pack->pages)) {
rc = -ENOMEM;
goto pages_arr_err;
}
@@ -887,7 +887,7 @@ static int init_phys_pg_pack_from_userptr(struct hl_ctx *ctx,
phys_pg_pack->pages = kvmalloc_array(total_npages, sizeof(u64),
GFP_KERNEL);
- if (ZERO_OR_NULL_PTR(phys_pg_pack->pages)) {
+ if (!(phys_pg_pack->pages)) {
rc = -ENOMEM;
goto page_pack_arr_mem_err;
}
diff --git a/drivers/accel/habanalabs/common/mmu/mmu.c b/drivers/accel/habanalabs/common/mmu/mmu.c
index 79823facce7f..a3cf14cf5abc 100644
--- a/drivers/accel/habanalabs/common/mmu/mmu.c
+++ b/drivers/accel/habanalabs/common/mmu/mmu.c
@@ -844,7 +844,7 @@ int hl_mmu_hr_init(struct hl_device *hdev, struct hl_mmu_hr_priv *hr_priv, u32 h
}
hr_priv->mmu_asid_hop0 = kvcalloc(prop->max_asid, sizeof(struct pgt_info), GFP_KERNEL);
- if (ZERO_OR_NULL_PTR(hr_priv->mmu_asid_hop0)) {
+ if (!(hr_priv->mmu_asid_hop0)) {
dev_err(hdev->dev, "Failed to allocate hr-mmu hop0 table\n");
rc = -ENOMEM;
goto destroy_mmu_pgt_pool;
--
2.25.1
Powered by blists - more mailing lists