Skip to contentSkip to conversation

fsl/fman: Free init resources on KeyGen failure in fman_init()

PATCH Applied Haoxiang Li 3 participants 3 messages Jun 25 – Jun 30

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 fsl/fman: Free init resources on KeyGen failure in fman_init()

fman_muram_alloc() allocates initialization resources before initializing the KeyGen block. If keygen_init() fails, the function returns -EINVAL directly and leaves those resources allocated. Free the initialization resources before returning from the KeyGen failure path.

Fixes 7472f4f281d0 ("fsl/fman: enable FMan Keygen")

---
Changes in v2:
- Add "net" to patch title. Thanks, Pavan!
Changes in v3:
- Drop the unrelated enable() cleanup from this fix. Thanks, Breno!

---
 drivers/net/ethernet/freescale/fman/fman.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/fman/fman.c +3 -1
index 013273a2de32..299bab043175 100644
@@ -1995,8 +1995,10 @@ static int fman_init(struct fman *fman)
 
 	/* Init KeyGen */
 	fman->keygen = keygen_init(fman->kg_regs);
-	if (!fman->keygen)
+	if (!fman->keygen) {
+		free_init_resources(fman);
 		return -EINVAL;
+	}
 
 	err = enable(fman, cfg);
 	if (err != 0)
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 5 lines · On Thu, 25 Jun 2026 08:48:34 +0800 Haoxiang Li wrote:

fman_muram_alloc() allocates initialization resources before initializing the KeyGen block. If keygen_init() fails, the function returns -EINVAL directly and leaves those resources allocated. Free the initialization resources before returning from the KeyGen failure path.

Please slow down. You're sending a lot of low value patches. Please do not have more than 5 outstanding "active" networking patches under name at any given time:

https://patchwork.kernel.org/project/netdevbpf/list/?submitter=215341

maintainer Applied
#2 lore raw
In reply to Haoxiang Li
Quoted 11 lines · Haoxiang Li

fman_muram_alloc() allocates initialization resources before initializing the KeyGen block. If keygen_init() fails, the function returns -EINVAL directly and leaves those resources allocated. Free the initialization resources before returning from the KeyGen failure path.

Fixes 7472f4f281d0 ("fsl/fman: enable FMan Keygen")

The PW bot is on holiday, no automated notifications for a while.

Applied, thanks!

/P