Skip to content

Commit 7f71acd

Browse files
michalQbgregkh
authored andcommitted
idpf: fix memleak in vport interrupt configuration
commit 3cc88e8 upstream. The initialization of vport interrupt consists of two functions: 1) idpf_vport_intr_init() where a generic configuration is done 2) idpf_vport_intr_req_irq() where the irq for each q_vector is requested. The first function used to create a base name for each interrupt using "kasprintf()" call. Unfortunately, although that call allocated memory for a text buffer, that memory was never released. Fix this by removing creating the interrupt base name in 1). Instead, always create a full interrupt name in the function 2), because there is no need to create a base name separately, considering that the function 2) is never called out of idpf_vport_intr_init() context. Fixes: d4d5587 ("idpf: initialize interrupts and enable vport") Cc: stable@vger.kernel.org # 6.7 Signed-off-by: Michal Kubiak <michal.kubiak@intel.com> Reviewed-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com> Reviewed-by: Simon Horman <horms@kernel.org> Tested-by: Krishneil Singh <krishneil.k.singh@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Link: https://patch.msgid.link/20240806220923.3359860-3-anthony.l.nguyen@intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3831170 commit 7f71acd

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

drivers/net/ethernet/intel/idpf/idpf_txrx.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3614,13 +3614,15 @@ void idpf_vport_intr_update_itr_ena_irq(struct idpf_q_vector *q_vector)
36143614
/**
36153615
* idpf_vport_intr_req_irq - get MSI-X vectors from the OS for the vport
36163616
* @vport: main vport structure
3617-
* @basename: name for the vector
36183617
*/
3619-
static int idpf_vport_intr_req_irq(struct idpf_vport *vport, char *basename)
3618+
static int idpf_vport_intr_req_irq(struct idpf_vport *vport)
36203619
{
36213620
struct idpf_adapter *adapter = vport->adapter;
3621+
const char *drv_name, *if_name, *vec_name;
36223622
int vector, err, irq_num, vidx;
3623-
const char *vec_name;
3623+
3624+
drv_name = dev_driver_string(&adapter->pdev->dev);
3625+
if_name = netdev_name(vport->netdev);
36243626

36253627
for (vector = 0; vector < vport->num_q_vectors; vector++) {
36263628
struct idpf_q_vector *q_vector = &vport->q_vectors[vector];
@@ -3637,8 +3639,8 @@ static int idpf_vport_intr_req_irq(struct idpf_vport *vport, char *basename)
36373639
else
36383640
continue;
36393641

3640-
q_vector->name = kasprintf(GFP_KERNEL, "%s-%s-%d",
3641-
basename, vec_name, vidx);
3642+
q_vector->name = kasprintf(GFP_KERNEL, "%s-%s-%s-%d", drv_name,
3643+
if_name, vec_name, vidx);
36423644

36433645
err = request_irq(irq_num, idpf_vport_intr_clean_queues, 0,
36443646
q_vector->name, q_vector);
@@ -4148,7 +4150,6 @@ int idpf_vport_intr_alloc(struct idpf_vport *vport)
41484150
*/
41494151
int idpf_vport_intr_init(struct idpf_vport *vport)
41504152
{
4151-
char *int_name;
41524153
int err;
41534154

41544155
err = idpf_vport_intr_init_vec_idx(vport);
@@ -4162,11 +4163,7 @@ int idpf_vport_intr_init(struct idpf_vport *vport)
41624163
if (err)
41634164
goto unroll_vectors_alloc;
41644165

4165-
int_name = kasprintf(GFP_KERNEL, "%s-%s",
4166-
dev_driver_string(&vport->adapter->pdev->dev),
4167-
vport->netdev->name);
4168-
4169-
err = idpf_vport_intr_req_irq(vport, int_name);
4166+
err = idpf_vport_intr_req_irq(vport);
41704167
if (err)
41714168
goto unroll_vectors_alloc;
41724169

0 commit comments

Comments
 (0)