[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20211004100944.15023-1-laurentiu.tudor@nxp.com>
Date: Mon, 4 Oct 2021 13:09:44 +0300
From: Laurentiu Tudor <laurentiu.tudor@....com>
To: linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc: leoyang.li@....com, youri.querry_1@....nxp.com,
ioana.ciornei@....com, Laurentiu Tudor <laurentiu.tudor@....com>
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 <laurentiu.tudor@....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
Powered by blists - more mailing lists