From: luoqing <[email protected]>

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 <[email protected]>
---
 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

Reply via email to