Skip to content

Commit

Permalink
soc: ti: k3-ringacc: Add try_module_get() to k3_dmaring_request_dual_…
Browse files Browse the repository at this point in the history
…ring()

[ Upstream commit 5f1732a ]

When the k3 ring accelerator driver has been modified to add module build
support, try_module_get() and module_put() have been added to update the
module refcnt. One code path has not been updated and it has introduced
an issue where the refcnt is decremented by module_put() in
k3_ringacc_ring_free() without being incremented previously.
Adding try_module_get() to k3_dmaring_request_dual_ring() ensures the
refcnt is kept up to date.

Fixes: c07f216 ("soc: ti: k3-ringacc: Allow the driver to be built as module")
Signed-off-by: Nicolas Frayer <nfrayer@baylibre.com>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
Link: https://lore.kernel.org/r/20221230001404.10902-1-nfrayer@baylibre.com
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Nicolas Frayer authored and gregkh committed May 11, 2023
1 parent a7eaf41 commit b479543
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/soc/ti/k3-ringacc.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,11 @@ static int k3_dmaring_request_dual_ring(struct k3_ringacc *ringacc, int fwd_id,

mutex_lock(&ringacc->req_lock);

if (!try_module_get(ringacc->dev->driver->owner)) {
ret = -EINVAL;
goto err_module_get;
}

if (test_bit(fwd_id, ringacc->rings_inuse)) {
ret = -EBUSY;
goto error;
Expand All @@ -421,6 +426,8 @@ static int k3_dmaring_request_dual_ring(struct k3_ringacc *ringacc, int fwd_id,
return 0;

error:
module_put(ringacc->dev->driver->owner);
err_module_get:
mutex_unlock(&ringacc->req_lock);
return ret;
}
Expand Down

0 comments on commit b479543

Please sign in to comment.