Skip to contentSkip to conversation

soc: ti: k3-ringacc: Add try_module_get() to k3_dmaring_request_dual_ring()

PATCH Applied Nicolas Frayer 2 participants 2 messages Dec 30, 2022 – Mar 8, 2023 TI Keystone multicore navigator drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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 c07f216a8b72 ("soc: ti: k3-ringacc: Allow the driver to be built as module")

---
v1->v2:
Added the Fixes and Reviewed-by tags

 drivers/soc/ti/k3-ringacc.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/soc/ti/k3-ringacc.c +7 -0
index e01e4d815230a..8f131368a7586 100644
@@ -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;
@@ -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;
 }
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw

Hi Nicolas Frayer,

Quoted 9 lines · Nicolas Frayer

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.

[...]

I have applied the following to branch ti-drivers-soc-next on [1]. Thank you!

[1/1] soc: ti: k3-ringacc: Add try_module_get() to k3_dmaring_request_dual_ring()

      commit: 5f1732a8683c1da8faaa90d6ffc3bd6d33013a58

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent up the chain during the next merge window (or sooner if it is a relevant bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

[1] git://git.kernel.org/pub/scm/linux/kernel/git/ti/linux.git

Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D