From: Igor Russkikh <irusskikh@marvell.com>
To: <netdev@vger.kernel.org>
Cc: <dbogdanov@marvell.com>, <pbelous@marvell.com>,
<ndanilov@marvell.com>, <davem@davemloft.net>,
Igor Russkikh <irusskikh@marvell.com>
Subject: [PATCH net 7/8] net: atlantic: possible fault in transition to hibernation
Date: Fri, 14 Feb 2020 18:44:57 +0300 [thread overview]
Message-ID: <06b9cfdc67a61c8f6b6b2aa6b9a0510513834b42.1580299250.git.irusskikh@marvell.com> (raw)
In-Reply-To: <cover.1580299250.git.irusskikh@marvell.com>
From: Pavel Belous <pbelous@marvell.com>
during hibernation freeze, aq_nic_stop could be invoked
on a stopped device. That may cause panic on access to
not yet allocated vector/ring structures.
Add a check to stop device if it is not yet stopped.
Similiarly after freeze in hibernation thaw, aq_nic_start
could be invoked on a not initialized net device.
Result will be the same.
Add a check to start device if it is initialized.
In our case, this is the same as started.
Fixes: 8aaa112a57c1 ("net: atlantic: refactoring pm logic")
Signed-off-by: Pavel Belous <pbelous@marvell.com>
Signed-off-by: Nikita Danilov <ndanilov@marvell.com>
Signed-off-by: Igor Russkikh <irusskikh@marvell.com>
Signed-off-by: Dmitry Bogdanov <dbogdanov@marvell.com>
---
.../net/ethernet/aquantia/atlantic/aq_pci_func.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
index 6b27af0db499..78b6f3248756 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
@@ -359,7 +359,8 @@ static int aq_suspend_common(struct device *dev, bool deep)
netif_device_detach(nic->ndev);
netif_tx_stop_all_queues(nic->ndev);
- aq_nic_stop(nic);
+ if (netif_running(nic->ndev))
+ aq_nic_stop(nic);
if (deep) {
aq_nic_deinit(nic, !nic->aq_hw->aq_nic_cfg->wol);
@@ -375,7 +376,7 @@ static int atl_resume_common(struct device *dev, bool deep)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct aq_nic_s *nic;
- int ret;
+ int ret = 0;
nic = pci_get_drvdata(pdev);
@@ -390,9 +391,11 @@ static int atl_resume_common(struct device *dev, bool deep)
goto err_exit;
}
- ret = aq_nic_start(nic);
- if (ret)
- goto err_exit;
+ if (netif_running(nic->ndev)) {
+ ret = aq_nic_start(nic);
+ if (ret)
+ goto err_exit;
+ }
netif_device_attach(nic->ndev);
netif_tx_start_all_queues(nic->ndev);
--
2.17.1
next prev parent reply other threads:[~2020-02-14 15:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-14 15:44 [PATCH net 0/8] Marvell atlantic 2020/02 updates Igor Russkikh
2020-02-14 15:44 ` [PATCH net 1/8] net: atlantic: checksum compat issue Igor Russkikh
2020-02-14 15:44 ` [PATCH net 2/8] net: atlantic: check rpc result and wait for rpc address Igor Russkikh
2020-02-14 15:44 ` [PATCH net 3/8] net: atlantic: ptp gpio adjustments Igor Russkikh
2020-02-14 15:44 ` [PATCH net 4/8] net: atlantic: better loopback mode handling Igor Russkikh
2020-02-14 15:44 ` [PATCH net 5/8] net: atlantic: fix use after free kasan warn Igor Russkikh
2020-02-14 15:44 ` [PATCH net 6/8] net: atlantic: fix potential error handling Igor Russkikh
2020-02-14 15:44 ` Igor Russkikh [this message]
2020-02-17 3:03 ` [PATCH net 0/8] Marvell atlantic 2020/02 updates David Miller
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=06b9cfdc67a61c8f6b6b2aa6b9a0510513834b42.1580299250.git.irusskikh@marvell.com \
--to=irusskikh@marvell.com \
--cc=davem@davemloft.net \
--cc=dbogdanov@marvell.com \
--cc=ndanilov@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=pbelous@marvell.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;
as well as URLs for NNTP newsgroup(s).