Skip to content

Commit 5f1732a

Browse files
Nicolas Frayernmenon
authored andcommitted
soc: ti: k3-ringacc: Add try_module_get() to k3_dmaring_request_dual_ring()
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 <[email protected]> Reviewed-by: Peter Ujfalusi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Nishanth Menon <[email protected]>
1 parent fe15c26 commit 5f1732a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/soc/ti/k3-ringacc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,11 @@ static int k3_dmaring_request_dual_ring(struct k3_ringacc *ringacc, int fwd_id,
406406

407407
mutex_lock(&ringacc->req_lock);
408408

409+
if (!try_module_get(ringacc->dev->driver->owner)) {
410+
ret = -EINVAL;
411+
goto err_module_get;
412+
}
413+
409414
if (test_bit(fwd_id, ringacc->rings_inuse)) {
410415
ret = -EBUSY;
411416
goto error;
@@ -421,6 +426,8 @@ static int k3_dmaring_request_dual_ring(struct k3_ringacc *ringacc, int fwd_id,
421426
return 0;
422427

423428
error:
429+
module_put(ringacc->dev->driver->owner);
430+
err_module_get:
424431
mutex_unlock(&ringacc->req_lock);
425432
return ret;
426433
}

0 commit comments

Comments
 (0)