mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 17:25:35 +03:00
misc: nvscic2c-pcie: fix leak/lock in deinit
- Fix missing leak for epc_ctx when probe() fails nvscic2c-pcie-epc - Fix mutex lock/unlock for syncpoint fence operations. Bug 4539983 Change-Id: I18272f991d6d9821ff1a7e13e9b4807cef20d92f Signed-off-by: Arihant Jejani <ajejani@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3087303 Reviewed-by: Deepak Kumar Badgaiyan <dbadgaiyan@nvidia.com> Reviewed-by: Vipin Kumar <vipink@nvidia.com> GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
3c36bb896e
commit
6a2c18b943
@@ -414,8 +414,10 @@ fence_do_work(struct work_struct *work)
|
|||||||
|
|
||||||
mutex_lock(&syncpt->lock);
|
mutex_lock(&syncpt->lock);
|
||||||
/* If deinit triggered, no need to proceed. */
|
/* If deinit triggered, no need to proceed. */
|
||||||
if (syncpt->fence_release)
|
if (syncpt->fence_release) {
|
||||||
|
mutex_unlock(&syncpt->lock);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (syncpt->fence) {
|
if (syncpt->fence) {
|
||||||
dma_fence_put(syncpt->fence);
|
dma_fence_put(syncpt->fence);
|
||||||
@@ -425,7 +427,6 @@ fence_do_work(struct work_struct *work)
|
|||||||
|
|
||||||
ret = allocate_fence(syncpt);
|
ret = allocate_fence(syncpt);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
mutex_unlock(&syncpt->lock);
|
|
||||||
pr_err("allocate_fence failed with: %d\n", ret);
|
pr_err("allocate_fence failed with: %d\n", ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -598,6 +598,7 @@ allocate_fence(struct syncpt_t *syncpt)
|
|||||||
mutex_lock(&syncpt->lock);
|
mutex_lock(&syncpt->lock);
|
||||||
ret = dma_fence_add_callback(fence, &syncpt->fence_cb, host1x_cb_func);
|
ret = dma_fence_add_callback(fence, &syncpt->fence_cb, host1x_cb_func);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
/* If already expired. */
|
||||||
if (ret == -ENOENT) {
|
if (ret == -ENOENT) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
schedule_work(&syncpt->work);
|
schedule_work(&syncpt->work);
|
||||||
@@ -626,8 +627,10 @@ fence_do_work(struct work_struct *work)
|
|||||||
|
|
||||||
mutex_lock(&syncpt->lock);
|
mutex_lock(&syncpt->lock);
|
||||||
/* If deinit triggered, no need to proceed. */
|
/* If deinit triggered, no need to proceed. */
|
||||||
if (syncpt->fence_release)
|
if (syncpt->fence_release) {
|
||||||
|
mutex_unlock(&syncpt->lock);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (syncpt->fence) {
|
if (syncpt->fence) {
|
||||||
dma_fence_put(syncpt->fence);
|
dma_fence_put(syncpt->fence);
|
||||||
syncpt->fence = NULL;
|
syncpt->fence = NULL;
|
||||||
@@ -636,7 +639,6 @@ fence_do_work(struct work_struct *work)
|
|||||||
|
|
||||||
ret = allocate_fence(syncpt);
|
ret = allocate_fence(syncpt);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
mutex_unlock(&syncpt->lock);
|
|
||||||
pr_err("allocate_fence failed with: %d\n", ret);
|
pr_err("allocate_fence failed with: %d\n", ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
// Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
// Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||||
|
|
||||||
#include <nvidia/conftest.h>
|
#include <nvidia/conftest.h>
|
||||||
|
|
||||||
@@ -491,6 +491,7 @@ err_enable_device:
|
|||||||
|
|
||||||
err_dt_parse:
|
err_dt_parse:
|
||||||
pci_set_drvdata(pdev, NULL);
|
pci_set_drvdata(pdev, NULL);
|
||||||
|
kfree(drv_ctx->epc_ctx);
|
||||||
kfree_const(drv_ctx->drv_name);
|
kfree_const(drv_ctx->drv_name);
|
||||||
kfree(drv_ctx);
|
kfree(drv_ctx);
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user