From patchwork Thu Mar 23 11:35:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 13185546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A1553C6FD1D for ; Thu, 23 Mar 2023 11:35:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D6F810EA6E; Thu, 23 Mar 2023 11:35:40 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7A6ED10E46E for ; Thu, 23 Mar 2023 11:35:36 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E13A062606; Thu, 23 Mar 2023 11:35:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6852FC4339B; Thu, 23 Mar 2023 11:35:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679571335; bh=WcoQqs1nDbhSzgIdgSJjl18bpwV96ePf17ORSFkoyLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NVlZLNNqqiymnGvf2krtB6MChFikZ3WjbK2XV6rSpzgqGysB901uoi3DbWkXZXnGJ rQqMqkC73ChTCHhFGv0yIlIpVIqfLnD9GavJ1J5di1hQ3DEa7EWdAVnh4cKK14G/mZ DPmW6jD+wbH9ESg3haCdydXQxluTkvxMcFqWRCcdqL18nx0o/Bbrh5ZGkk1JUyCg8u hSzGcCOutH2qA4W5prkGmaEa0sggkfhnIIrcl8z5BJgm8ep1gh5F5KCCyKL3GG+JZZ xJtbFLppRwH8uM7g1TxO1qJPYbR53pndIlPdVKUs8ONOw1DPJaDCGKaf3+g1COXdOP Mgc4UhBXV73VA== From: Oded Gabbay To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/6] accel/habanalabs: check return value of add_va_block_locked Date: Thu, 23 Mar 2023 13:35:22 +0200 Message-Id: <20230323113525.959176-3-ogabbay@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230323113525.959176-1-ogabbay@kernel.org> References: <20230323113525.959176-1-ogabbay@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dafna Hirschfeld Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dafna Hirschfeld since the function might fail and we should propagate the failure. Signed-off-by: Dafna Hirschfeld Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay Reviewed-by: Stanislaw Gruszka --- drivers/accel/habanalabs/common/memory.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/accel/habanalabs/common/memory.c b/drivers/accel/habanalabs/common/memory.c index 17b79d717896..a7b6a273ce21 100644 --- a/drivers/accel/habanalabs/common/memory.c +++ b/drivers/accel/habanalabs/common/memory.c @@ -605,6 +605,7 @@ static u64 get_va_block(struct hl_device *hdev, bool is_align_pow_2 = is_power_of_2(va_range->page_size); bool is_hint_dram_addr = hl_is_dram_va(hdev, hint_addr); bool force_hint = flags & HL_MEM_FORCE_HINT; + int rc; if (is_align_pow_2) align_mask = ~((u64)va_block_align - 1); @@ -722,9 +723,13 @@ static u64 get_va_block(struct hl_device *hdev, kfree(new_va_block); } - if (add_prev) - add_va_block_locked(hdev, &va_range->list, prev_start, - prev_end); + if (add_prev) { + rc = add_va_block_locked(hdev, &va_range->list, prev_start, prev_end); + if (rc) { + reserved_valid_start = 0; + goto out; + } + } print_va_list_locked(hdev, &va_range->list); out: