idpf: Fix vport IRQ name leak on request failure
Subsystems (3)
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").
---
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
@@ -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
Simon Horman
reviewerQuoted 10 lines · Yuho Choi
idpf_vport_intr_req_irq()allocates a name for each vector IRQ before callingrequest_irq(). On success, the name is released later through kfree(free_irq()), but whenrequest_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 commit9bff30482c10("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
Signed-off-by Yuho Choi <[email protected]>---
Compile-tested only (x86_64defconfig +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
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
-0goto free_q_irqs; }
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 aroundkvasprintf_const(). Andkvasprintf_const()documents that it's return value should be freed usingkfree_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
Simon Horman
reviewerQuoted 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 aroundkvasprintf_const(). Andkvasprintf_const()documents that it's return value should be freed usingkfree_const(). I don't think it will make any run-time difference here, but perhaps it would be best to follow that convention.
kasprintf()useskvasprintf(), notkvasprintf_const(), so the name is always kmalloc'ed andkfree()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
Romanowski, Rafal
Tested-byQuoted 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 failureQuoted 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 aroundkvasprintf_const(). Andkvasprintf_const()documents that it's return value should be freed usingkfree_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()useskvasprintf(), notkvasprintf_const(), so the name is always kmalloc'ed andkfree()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