mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nishanth Menon <nm@ti.com>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Eric Dumazet" <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>
Cc: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	"Vadapalli, Siddharth" <s-vadapalli@ti.com>,
	Nishanth Menon <nm@ti.com>
Subject: [PATCH] net: netcp: Fix crash in error path when DMA channel open fails
Date: Fri, 26 Sep 2025 10:08:53 -0500	[thread overview]
Message-ID: <20250926150853.2907028-1-nm@ti.com> (raw)

When knav_dma_open_channel() fails in netcp_setup_navigator_resources(),
the rx_channel field is set to an ERR_PTR value. Later, when
netcp_free_navigator_resources() is called in the error path, it attempts
to close this invalid channel pointer, causing a crash.

Add a check for ERR values to handle the failure scenario.

Fixes: 84640e27f230 ("net: netcp: Add Keystone NetCP core driver")
Signed-off-by: Nishanth Menon <nm@ti.com>
---

Seen on kci log for k2hk: https://dashboard.kernelci.org/log-viewer?itemId=ti%3A2eb55ed935eb42c292e02f59&org=ti&type=test&url=http%3A%2F%2Ffiles.kernelci.org%2F%2Fti%2Fmainline%2Fmaster%2Fv6.17-rc7-59-gbf40f4b87761%2Farm%2Fmulti_v7_defconfig%2BCONFIG_EFI%3Dy%2BCONFIG_ARM_LPAE%3Dy%2Bdebug%2Bkselftest%2Btinyconfig%2Fgcc-12%2Fbaseline-nfs-boot.nfs-k2hk-evm.txt.gz

 drivers/net/ethernet/ti/netcp_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index 857820657bac..4ff17fd6caae 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -1549,7 +1549,7 @@ static void netcp_free_navigator_resources(struct netcp_intf *netcp)
 {
 	int i;
 
-	if (netcp->rx_channel) {
+	if (!IS_ERR(netcp->rx_channel)) {
 		knav_dma_close_channel(netcp->rx_channel);
 		netcp->rx_channel = NULL;
 	}
-- 
2.47.0


             reply	other threads:[~2025-09-26 15:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-26 15:08 Nishanth Menon [this message]
2025-09-26 16:13 ` Simon Horman
2025-09-26 16:27   ` Siddharth Vadapalli
2025-09-26 16:42     ` Simon Horman
2025-09-26 16:58       ` Siddharth Vadapalli
2025-09-29  9:59         ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250926150853.2907028-1-nm@ti.com \
    --to=nm@ti.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=s-vadapalli@ti.com \
    --cc=u.kleine-koenig@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®