Skip to contentSkip to conversation

ionic: catch NULL pointer issue on reconfig

PATCH Applied Shannon Nelson 2 participants 2 messages Oct 17, 2022 – Oct 19, 2022

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

PATCH 1/1 ionic: catch NULL pointer issue on reconfig

From: Brett Creeley <[email protected]>

It's possible that the driver will dereference a qcq that doesn't exist when calling ionic_reconfigure_queues(), which causes a page fault BUG.

If a reduction in the number of queues is followed by a different reconfig such as changing the ring size, the driver can hit a NULL pointer when trying to clean up non-existent queues.

Fix this by checking to make sure both the qcqs array and qcq entry exists bofore trying to use and free the entry.

Fixes 101b40a0171f ("ionic: change queue count with no reset")
---
 drivers/net/ethernet/pensando/ionic/ionic_lif.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +8 -4
index 5d58fd99be3c..19d4848df17d 100644
@@ -2817,11 +2817,15 @@ int ionic_reconfigure_queues(struct ionic_lif *lif,
 	 * than the full array, but leave the qcq shells in place
 	 */
 	for (i = lif->nxqs; i < lif->ionic->ntxqs_per_lif; i++) {
-		lif->txqcqs[i]->flags &= ~IONIC_QCQ_F_INTR;
-		ionic_qcq_free(lif, lif->txqcqs[i]);
+		if (lif->txqcqs && lif->txqcqs[i]) {
+			lif->txqcqs[i]->flags &= ~IONIC_QCQ_F_INTR;
+			ionic_qcq_free(lif, lif->txqcqs[i]);
+		}
 
-		lif->rxqcqs[i]->flags &= ~IONIC_QCQ_F_INTR;
-		ionic_qcq_free(lif, lif->rxqcqs[i]);
+		if (lif->rxqcqs && lif->rxqcqs[i]) {
+			lif->rxqcqs[i]->flags &= ~IONIC_QCQ_F_INTR;
+			ionic_qcq_free(lif, lif->rxqcqs[i]);
+		}
 	}
 
 	if (err)
Signature · 1 line
2.17.1
#1 lore raw
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Mon, 17 Oct 2022 16:31:23 -0700 you wrote:

From: Brett Creeley <[email protected]>

It's possible that the driver will dereference a qcq that doesn't exist when calling ionic_reconfigure_queues(), which causes a page fault BUG.

If a reduction in the number of queues is followed by a different reconfig such as changing the ring size, the driver can hit a NULL pointer when trying to clean up non-existent queues.

[...]

Here is the summary with links:
- [net] ionic: catch NULL pointer issue on reconfig

    https://git.kernel.org/netdev/net/c/aa1d7e1267c1

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html