2021-10-04 10:11:33

by Laurentiu Tudor

[permalink] [raw]
Subject: [PATCH] soc: dpio: fix cleanup on error

dpaa2_io_service_register() adds an element to a linked list but
doesn't remove it on the error path, leaking it. Fix it.

Signed-off-by: Laurentiu Tudor <[email protected]>
---
drivers/soc/fsl/dpio/dpio-service.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/soc/fsl/dpio/dpio-service.c b/drivers/soc/fsl/dpio/dpio-service.c
index 7351f3030550..b42367eb1653 100644
--- a/drivers/soc/fsl/dpio/dpio-service.c
+++ b/drivers/soc/fsl/dpio/dpio-service.c
@@ -278,10 +278,20 @@ int dpaa2_io_service_register(struct dpaa2_io *d,
spin_unlock_irqrestore(&d->lock_notifications, irqflags);

/* Enable the generation of CDAN notifications */
- if (ctx->is_cdan)
- return qbman_swp_CDAN_set_context_enable(d->swp,
- (u16)ctx->id,
- ctx->qman64);
+ if (ctx->is_cdan) {
+ int ret;
+
+ ret = qbman_swp_CDAN_set_context_enable(d->swp, (u16)ctx->id,
+ ctx->qman64);
+ if (ret) {
+ spin_lock_irqsave(&d->lock_notifications, irqflags);
+ list_del(&ctx->node);
+ spin_unlock_irqrestore(&d->lock_notifications,
+ irqflags);
+
+ return ret;
+ }
+ }
return 0;
}
EXPORT_SYMBOL_GPL(dpaa2_io_service_register);
--
2.17.1