Skip to contentSkip to conversation

idpf: Fix vport IRQ name leak on request failure

PATCH Superseded Yuho Choi 3 participants 5 messages Sep 23 – Oct 30

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yuho Choi

author
#0 lore raw

PATCH 1/1 idpf: Fix vport IRQ name leak on request failure

idpf_vport_intr_req_irq() allocates a name for each vector IRQ before calling request_irq(). On success, the name is released later through kfree(free_irq()), but when request_irq() fails, the error path only unwinds the previous vectors and the name for the failed one is leaked.

Free the allocated name on the request_irq() failure path, as done for the mailbox IRQ in commit 9bff30482c10 ("idpf: Fix mailbox IRQ name leak on request failure").

Fixes bf9bf7042a38 ("idpf: avoid bloating &idpf_q_vector with big %NR_CPUS")

---
Compile-tested only (x86_64 defconfig + CONFIG_IDPF=m, W=1).

 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +1 -0
index 4311ffa30bb1..e7d5e7923371 100644
@@ -4073,6 +4073,7 @@ static int idpf_vport_intr_req_irq(struct idpf_vport *vport,
 		if (err) {
 			netdev_err(vport->netdev,
 				   "Request_irq failed, error: %d\n", err);
+			kfree(name);
 			goto free_q_irqs;
 		}
 

base-commit: f0100363d8c374bd8e9ea7c9ba02744f0b802ca4

Signature · 1 line
2.43.0
reviewer
#1 lore raw
Quoted 10 lines · Yuho Choi

idpf_vport_intr_req_irq() allocates a name for each vector IRQ before calling request_irq(). On success, the name is released later through kfree(free_irq()), but when request_irq() fails, the error path only unwinds the previous vectors and the name for the failed one is leaked.

Free the allocated name on the request_irq() failure path, as done for the mailbox IRQ in commit 9bff30482c10 ("idpf: Fix mailbox IRQ name leak on request failure").

Fixes bf9bf7042a38 ("idpf: avoid bloating &idpf_q_vector with big %NR_CPUS")

I don't believe that commit introduced this problem.

Quoted 12 lines

---
Compile-tested only (x86_64 defconfig + CONFIG_IDPF=m, W=1).

 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +0 -0
index 4311ffa30bb1..e7d5e7923371 100644

drivers/net/ethernet/intel/idpf/idpf_txrx.c static int idpf_vport_intr_req_irq(struct idpf_vport *vport, · line 4076

Quoted 4 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +1 -0
@@ -4073,6 +4073,7 @@ static int idpf_vport_intr_req_irq(struct idpf_vport *vport,
 		if (err) {
 			netdev_err(vport->netdev,
 				   "Request_irq failed, error: %d\n", err);
+			kfree(name);

name is allocated by kasprintf() which is a wrapper around kvasprintf_const(). And kvasprintf_const() documents that it's return value should be freed using kfree_const(). I don't think it will make any run-time difference here, but perhaps it would be best to follow that convention.

Also, for completeness, shouldn't there be error handling for the case where the allocation of name fails?

Quoted 2 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +0 -0
 			goto free_q_irqs;
 		}
author
#2 lore raw

I appreciate your time to review this.

Quoted 4 lines · Simon Horman
Quoted 2 lines
Fixes bf9bf7042a38 ("idpf: avoid bloating &idpf_q_vector with big %NR_CPUS")

I don't believe that commit introduced this problem.

Thanks for catching this. I'll fix this tag.

Quoted 4 lines

name is allocated by kasprintf() which is a wrapper around kvasprintf_const(). And kvasprintf_const() documents that it's return value should be freed using kfree_const(). I don't think it will make any run-time difference here, but perhaps it would be best to follow that convention.

kasprintf() uses kvasprintf(), not kvasprintf_const(), so the name is always kmalloc'ed and kfree() matches the kfree(free_irq()) used on the normal path. Please correct me if I'm wrong.

Quoted 3 lines

Also, for completeness, shouldn't there be error handling for the case where the allocation of name fails?

Agreed, I'll add it in v2

reviewer
#3 lore raw
Quoted 10 lines · Yuho Choi

I appreciate your time to review this.

Quoted 4 lines · Simon Horman
Quoted 2 lines
Fixes bf9bf7042a38 ("idpf: avoid bloating &idpf_q_vector with big %NR_CPUS")

I don't believe that commit introduced this problem.

Thanks for catching this. I'll fix this tag.

Quoted 8 lines
Quoted 4 lines

name is allocated by kasprintf() which is a wrapper around kvasprintf_const(). And kvasprintf_const() documents that it's return value should be freed using kfree_const(). I don't think it will make any run-time difference here, but perhaps it would be best to follow that convention.

kasprintf() uses kvasprintf(), not kvasprintf_const(), so the name is always kmalloc'ed and kfree() matches the kfree(free_irq()) used on the normal path. Please correct me if I'm wrong.

Yes, of course you are right.
No idea how I managed to muddle that one up.
Sorry for the noise.

Quoted 6 lines
Quoted 4 lines

Also, for completeness, shouldn't there be error handling for the case where the allocation of name fails?

Agreed, I'll add it in v2

#4 lore raw
Quoted 27 lines

-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Tuesday, October 6, 2026 5:11 PM
To: Yuho Choi <[email protected]>
Cc: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Lobakin, Aleksander <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH net v1] idpf: Fix vport IRQ name leak on request failure

Quoted 16 lines · Yuho Choi

I appreciate your time to review this.

Quoted 5 lines · Simon Horman
Quoted 3 lines
Fixes bf9bf7042a38 ("idpf: avoid bloating &idpf_q_vector with big

%NR_CPUS")

I don't believe that commit introduced this problem.

Thanks for catching this. I'll fix this tag.

Quoted 4 lines

name is allocated by kasprintf() which is a wrapper around kvasprintf_const(). And kvasprintf_const() documents that it's return value should be freed using kfree_const(). I don't think it will make any run-time difference here, but perhaps it would be best to follow that convention.

Quoted 14 lines
Quoted 3 lines

kasprintf() uses kvasprintf(), not kvasprintf_const(), so the name is always kmalloc'ed and kfree() matches the kfree(free_irq()) used on the normal path. Please correct me if I'm wrong.

Yes, of course you are right.
No idea how I managed to muddle that one up. Sorry for the noise.

Quoted 6 lines
Quoted 4 lines

Also, for completeness, shouldn't there be error handling for the case where the allocation of name fails?

Agreed, I'll add it in v2