habanalabs: free signal handle on failure

Fix a bug where in case of failure to allocate idr, the handle's
memory wasn't freed as part of the error handling code.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
This commit is contained in:
Oded Gabbay 2021-11-30 14:54:53 +02:00
parent b166465452
commit fee187fe46
1 changed files with 3 additions and 1 deletions

View File

@ -1838,7 +1838,7 @@ static int cs_ioctl_reserve_signals(struct hl_fpriv *hpriv,
if (hdl_id < 0) { if (hdl_id < 0) {
dev_err(hdev->dev, "Failed to allocate IDR for a new signal reservation\n"); dev_err(hdev->dev, "Failed to allocate IDR for a new signal reservation\n");
rc = -EINVAL; rc = -EINVAL;
goto out; goto free_handle;
} }
handle->id = hdl_id; handle->id = hdl_id;
@ -1891,7 +1891,9 @@ remove_idr:
idr_remove(&mgr->handles, hdl_id); idr_remove(&mgr->handles, hdl_id);
spin_unlock(&mgr->lock); spin_unlock(&mgr->lock);
free_handle:
kfree(handle); kfree(handle);
out: out:
return rc; return rc;
} }