[PATCH -next] habanalabs: fix return value check in hl_fw_get_sec_attest_data()

Yang Yingliang posted 1 patch 4 days, 11 hours ago
drivers/misc/habanalabs/common/firmware_if.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH -next] habanalabs: fix return value check in hl_fw_get_sec_attest_data()
Posted by Yang Yingliang 4 days, 11 hours ago
If hl_cpu_accessible_dma_pool_alloc() fails, we should check
'req_cpu_addr', fix it.

Fixes: 0c88760f8f5e ("habanalabs/gaudi2: add secured attestation info uapi")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/misc/habanalabs/common/firmware_if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/habanalabs/common/firmware_if.c b/drivers/misc/habanalabs/common/firmware_if.c
index 2de6a9bd564d..f18e53bbba6b 100644
--- a/drivers/misc/habanalabs/common/firmware_if.c
+++ b/drivers/misc/habanalabs/common/firmware_if.c
@@ -2983,7 +2983,7 @@ static int hl_fw_get_sec_attest_data(struct hl_device *hdev, u32 packet_id, void
 	int rc;
 
 	req_cpu_addr = hl_cpu_accessible_dma_pool_alloc(hdev, size, &req_dma_addr);
-	if (!data) {
+	if (!req_cpu_addr) {
 		dev_err(hdev->dev,
 			"Failed to allocate DMA memory for CPU-CP packet %u\n", packet_id);
 		return -ENOMEM;
-- 
2.25.1
Re: [PATCH -next] habanalabs: fix return value check in hl_fw_get_sec_attest_data()
Posted by Oded Gabbay 1 day, 15 hours ago
On Fri, Sep 23, 2022 at 5:32 PM Yang Yingliang <yangyingliang@huawei.com> wrote:
>
> If hl_cpu_accessible_dma_pool_alloc() fails, we should check
> 'req_cpu_addr', fix it.
>
> Fixes: 0c88760f8f5e ("habanalabs/gaudi2: add secured attestation info uapi")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/misc/habanalabs/common/firmware_if.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/habanalabs/common/firmware_if.c b/drivers/misc/habanalabs/common/firmware_if.c
> index 2de6a9bd564d..f18e53bbba6b 100644
> --- a/drivers/misc/habanalabs/common/firmware_if.c
> +++ b/drivers/misc/habanalabs/common/firmware_if.c
> @@ -2983,7 +2983,7 @@ static int hl_fw_get_sec_attest_data(struct hl_device *hdev, u32 packet_id, void
>         int rc;
>
>         req_cpu_addr = hl_cpu_accessible_dma_pool_alloc(hdev, size, &req_dma_addr);
> -       if (!data) {
> +       if (!req_cpu_addr) {
>                 dev_err(hdev->dev,
>                         "Failed to allocate DMA memory for CPU-CP packet %u\n", packet_id);
>                 return -ENOMEM;
> --
> 2.25.1
>

Thanks!
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>

Applied to -next.
Oded