[PATCH] soc: dpio: fix cleanup on error
Laurentiu Tudor
laurentiu.tudor at nxp.com
Mon Oct 4 03:09:44 PDT 2021
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 <laurentiu.tudor at nxp.com>
---
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
More information about the linux-arm-kernel
mailing list