netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Andre Przywara <andre.przywara@arm.com>,
	Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH AUTOSEL 5.6 110/149] net: axienet: Propagate failure of DMA descriptor setup
Date: Sat, 11 Apr 2020 19:03:07 -0400	[thread overview]
Message-ID: <20200411230347.22371-110-sashal@kernel.org> (raw)
In-Reply-To: <20200411230347.22371-1-sashal@kernel.org>

From: Andre Przywara <andre.przywara@arm.com>

[ Upstream commit ee44d0b78839b21591501424fd3cb3648cc803b5 ]

When we fail allocating the DMA buffers in axienet_dma_bd_init(), we
report this error, but carry on with initialisation nevertheless.

This leads to a kernel panic when the driver later wants to send a
packet, as it uses uninitialised data structures.

Make the axienet_device_reset() routine return an error value, as it
contains the DMA buffer initialisation. Make sure we propagate the error
up the chain and eventually fail the driver initialisation, to avoid
relying on non-initialised buffers.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../net/ethernet/xilinx/xilinx_axienet_main.c | 26 ++++++++++++++-----
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 7cebd5150bec4..d25548cca9d93 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -437,9 +437,10 @@ static void axienet_setoptions(struct net_device *ndev, u32 options)
 	lp->options |= options;
 }
 
-static void __axienet_device_reset(struct axienet_local *lp)
+static int __axienet_device_reset(struct axienet_local *lp)
 {
 	u32 timeout;
+
 	/* Reset Axi DMA. This would reset Axi Ethernet core as well. The reset
 	 * process of Axi DMA takes a while to complete as all pending
 	 * commands/transfers will be flushed or completed during this
@@ -455,9 +456,11 @@ static void __axienet_device_reset(struct axienet_local *lp)
 		if (--timeout == 0) {
 			netdev_err(lp->ndev, "%s: DMA reset timeout!\n",
 				   __func__);
-			break;
+			return -ETIMEDOUT;
 		}
 	}
+
+	return 0;
 }
 
 /**
@@ -470,13 +473,17 @@ static void __axienet_device_reset(struct axienet_local *lp)
  * areconnected to Axi Ethernet reset lines, this in turn resets the Axi
  * Ethernet core. No separate hardware reset is done for the Axi Ethernet
  * core.
+ * Returns 0 on success or a negative error number otherwise.
  */
-static void axienet_device_reset(struct net_device *ndev)
+static int axienet_device_reset(struct net_device *ndev)
 {
 	u32 axienet_status;
 	struct axienet_local *lp = netdev_priv(ndev);
+	int ret;
 
-	__axienet_device_reset(lp);
+	ret = __axienet_device_reset(lp);
+	if (ret)
+		return ret;
 
 	lp->max_frm_size = XAE_MAX_VLAN_FRAME_SIZE;
 	lp->options |= XAE_OPTION_VLAN;
@@ -491,9 +498,11 @@ static void axienet_device_reset(struct net_device *ndev)
 			lp->options |= XAE_OPTION_JUMBO;
 	}
 
-	if (axienet_dma_bd_init(ndev)) {
+	ret = axienet_dma_bd_init(ndev);
+	if (ret) {
 		netdev_err(ndev, "%s: descriptor allocation failed\n",
 			   __func__);
+		return ret;
 	}
 
 	axienet_status = axienet_ior(lp, XAE_RCW1_OFFSET);
@@ -518,6 +527,8 @@ static void axienet_device_reset(struct net_device *ndev)
 	axienet_setoptions(ndev, lp->options);
 
 	netif_trans_update(ndev);
+
+	return 0;
 }
 
 /**
@@ -921,8 +932,9 @@ static int axienet_open(struct net_device *ndev)
 	 */
 	mutex_lock(&lp->mii_bus->mdio_lock);
 	axienet_mdio_disable(lp);
-	axienet_device_reset(ndev);
-	ret = axienet_mdio_enable(lp);
+	ret = axienet_device_reset(ndev);
+	if (ret == 0)
+		ret = axienet_mdio_enable(lp);
 	mutex_unlock(&lp->mii_bus->mdio_lock);
 	if (ret < 0)
 		return ret;
-- 
2.20.1


  parent reply	other threads:[~2020-04-11 23:44 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-11 23:01 [PATCH AUTOSEL 5.6 001/149] net: hns3: drop the WQ_MEM_RECLAIM flag when allocating WQ Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 002/149] net: wan: wanxl: use allow to pass CROSS_COMPILE_M68k for rebuilding firmware Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 003/149] netfilter: ctnetlink: be more strict when NF_CONNTRACK_MARK is not set Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 004/149] net: axienet: Convert DMA error handler to a work queue Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 005/149] net: phy: probe PHY drivers synchronously Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 011/149] ionic: check for NULL structs on teardown Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 012/149] net: phy: mscc: accept all RGMII species in vsc85xx_mac_if_set Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 017/149] ath11k: Adding proper validation before accessing tx_stats Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 022/149] selftests/bpf: Fix test_progs's parsing of test numbers Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 024/149] net/mlx5: E-Switch, Hold mutex when querying drop counter in legacy mode Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 025/149] libbpf: Ignore incompatible types with matching name during CO-RE relocation Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 028/149] ath10k: use kzalloc to read for ath10k_sdio_hif_diag_read Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 029/149] mwifiex: set needed_headroom, not hard_header_len Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 030/149] Bluetooth: L2CAP: handle l2cap config request during open state Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 032/149] ath10k: fix not registering airtime of 11a station with WMM disable Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 034/149] net: phylink: Add missing Backplane speeds Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 035/149] net/mlx5e: Init ethtool steering for representors Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 037/149] Bluetooth: Fix calculation of SCO handle for packet processing Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 038/149] net: rmnet: add missing module alias Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 041/149] Bluetooth: guard against controllers sending zero'd events Sasha Levin
2020-04-11 23:01 ` [PATCH AUTOSEL 5.6 042/149] libbpf: Fix handling of optional field_name in btf_dump__emit_type_decl Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 050/149] net: hns3: modify an unsuitable print when setting unknown duplex to fibre Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 052/149] net: intel: e1000e: fix possible sleep-in-atomic-context bugs in e1000e_get_hw_semaphore() Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 053/149] net: dsa: bcm_sf2: Also configure Port 5 for 2Gb/sec on 7278 Sasha Levin
2020-04-12  1:16   ` Florian Fainelli
2020-04-17 17:06     ` Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 054/149] sh_eth: check sh_eth_cpu_data::no_tx_cntrs when dumping registers Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 055/149] sh_eth: check sh_eth_cpu_data::cexcr " Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 056/149] sh_eth: check sh_eth_cpu_data::no_xdfar " Sasha Levin
2020-04-12  9:30   ` Sergei Shtylyov
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 057/149] ice: Fix implicit queue mapping mode in ice_vsi_get_qs Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 058/149] ice: Add helper to determine if VF link is up Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 060/149] mt76: mt7615: disable 5 GHz on MT7622 Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 061/149] mt76: fix handling full tx queues in mt76_dma_tx_queue_skb_raw Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 062/149] rtw88: Fix incorrect beamformee role setting Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 067/149] rtw88: 8822c: update power sequence to v16 Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 078/149] ath11k: fix warn-on in disassociation Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 079/149] ath11k: Fixing dangling pointer issue upon peer delete failure Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 080/149] rsi: fix null pointer dereference during rsi_shutdown() Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 084/149] mt76: mt7603: fix input validation issues for powersave-filtered frames Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 096/149] Bluetooth: RFCOMM: fix ODEBUG bug in rfcomm_dev_ioctl Sasha Levin
2020-04-11 23:02 ` [PATCH AUTOSEL 5.6 098/149] ath10k: start recovery process when read int status fail for sdio Sasha Levin
2020-04-11 23:03 ` Sasha Levin [this message]
2020-04-11 23:03 ` [PATCH AUTOSEL 5.6 111/149] brcmfmac: Fix driver crash on USB control transfer timeout Sasha Levin
2020-04-11 23:03 ` [PATCH AUTOSEL 5.6 112/149] brcmfmac: Fix double freeing in the fmac usb data path Sasha Levin
2020-04-11 23:03 ` [PATCH AUTOSEL 5.6 113/149] brcmfmac: fix the incorrect return value in brcmf_inform_single_bss() Sasha Levin
2020-04-11 23:03 ` [PATCH AUTOSEL 5.6 114/149] xfrm: add prep for esp beet mode offload Sasha Levin
2020-04-11 23:03 ` [PATCH AUTOSEL 5.6 117/149] netfilter: nf_tables: silence a RCU-list warning in nft_table_lookup() Sasha Levin
2020-04-11 23:03 ` [PATCH AUTOSEL 5.6 147/149] svcrdma: Fix leak of transport addresses Sasha Levin

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=20200411230347.22371-110-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=andre.przywara@arm.com \
    --cc=davem@davemloft.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=radhey.shyam.pandey@xilinx.com \
    --cc=stable@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).