Skip to content

Commit

Permalink
octeon_ep: Fix irq releasing in the error handling path of octep_requ…
Browse files Browse the repository at this point in the history
…est_irqs()

When taken, the error handling path does not undo correctly what has
already been allocated.

Introduce a new loop index, 'j', in order to simplify the error handling
path and rewrite part of it.
It is now written with the same logic and intermediate variables used
when resources are allocated. This is much more straightforward.

Fixes: 37d79d0 ("octeon_ep: add Tx/Rx processing and interrupt support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Christophe JAILLET authored and Jakub Kicinski committed May 19, 2022
1 parent 4d3bf6f commit 3588c18
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions drivers/net/ethernet/marvell/octeon_ep/octep_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static int octep_request_irqs(struct octep_device *oct)
struct msix_entry *msix_entry;
char **non_ioq_msix_names;
int num_non_ioq_msix;
int ret, i;
int ret, i, j;

num_non_ioq_msix = CFG_GET_NON_IOQ_MSIX(oct->conf);
non_ioq_msix_names = CFG_GET_NON_IOQ_MSIX_NAMES(oct->conf);
Expand Down Expand Up @@ -233,34 +233,37 @@ static int octep_request_irqs(struct octep_device *oct)
}

/* Request IRQs for Tx/Rx queues */
for (i = 0; i < oct->num_oqs; i++) {
ioq_vector = oct->ioq_vector[i];
msix_entry = &oct->msix_entries[i + num_non_ioq_msix];
for (j = 0; j < oct->num_oqs; j++) {
ioq_vector = oct->ioq_vector[j];
msix_entry = &oct->msix_entries[j + num_non_ioq_msix];

snprintf(ioq_vector->name, sizeof(ioq_vector->name),
"%s-q%d", netdev->name, i);
"%s-q%d", netdev->name, j);
ret = request_irq(msix_entry->vector,
octep_ioq_intr_handler, 0,
ioq_vector->name, ioq_vector);
if (ret) {
netdev_err(netdev,
"request_irq failed for Q-%d; err=%d",
i, ret);
j, ret);
goto ioq_irq_err;
}

cpumask_set_cpu(i % num_online_cpus(),
cpumask_set_cpu(j % num_online_cpus(),
&ioq_vector->affinity_mask);
irq_set_affinity_hint(msix_entry->vector,
&ioq_vector->affinity_mask);
}

return 0;
ioq_irq_err:
while (i > num_non_ioq_msix) {
--i;
irq_set_affinity_hint(oct->msix_entries[i].vector, NULL);
free_irq(oct->msix_entries[i].vector, oct->ioq_vector[i]);
while (j) {
--j;
ioq_vector = oct->ioq_vector[j];
msix_entry = &oct->msix_entries[j + num_non_ioq_msix];

irq_set_affinity_hint(msix_entry->vector, NULL);
free_irq(msix_entry->vector, ioq_vector);
}
non_ioq_irq_err:
while (i) {
Expand Down

0 comments on commit 3588c18

Please sign in to comment.