From: alexandre.besnard@softathome.com
To: davem@davemloft.net, ktkhai@virtuozzo.com, ecree@solarflare.com,
jiri@mellanox.com, petrm@mellanox.com,
alexander.h.duyck@intel.com, amritha.nambiar@intel.com,
lirongqing@baidu.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Alexandre Besnard <alexandre.besnard@softathome.com>
Subject: [PATCH] net: check negative value for signed refcnt
Date: Thu, 31 Jan 2019 14:20:08 +0100 [thread overview]
Message-ID: <20190131132008.23161-1-alexandre.besnard@softathome.com> (raw)
From: Alexandre Besnard <alexandre.besnard@softathome.com>
Device remaining references counter is get as a signed integer.
When unregistering network devices, the loop waiting for this counter
to decrement tests the 0 strict equality. Thus if an error occurs and
two references are given back by a protocol, we are stuck in the loop
forever, with a -1 value.
Robustness is added by checking a negative value: the device is then
considered free of references, and a warning is issued (it should not
happen, one should check that behavior)
Signed-off-by: Alexandre Besnard <alexandre.besnard@softathome.com>
---
net/core/dev.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/core/dev.c b/net/core/dev.c
index ddc551f..e4190ae 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -8687,6 +8687,11 @@ static void netdev_wait_allrefs(struct net_device *dev)
refcnt = netdev_refcnt_read(dev);
while (refcnt != 0) {
+ if (refcnt < 0) {
+ pr_warn("Device %s refcnt negative: device considered free, but it should not happen\n",
+ dev->name);
+ break;
+ }
if (time_after(jiffies, rebroadcast_time + 1 * HZ)) {
rtnl_lock();
--
2.7.4
next reply other threads:[~2019-01-31 13:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-31 13:20 alexandre.besnard [this message]
2019-01-31 13:49 ` [PATCH] net: check negative value for signed refcnt Kirill Tkhai
2019-01-31 15:14 ` Alexandre BESNARD
2019-01-31 15:31 ` Kirill Tkhai
2019-01-31 15:15 ` Eric Dumazet
2019-01-31 15:21 ` Eric Dumazet
2019-01-31 15:34 ` Kirill Tkhai
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=20190131132008.23161-1-alexandre.besnard@softathome.com \
--to=alexandre.besnard@softathome.com \
--cc=alexander.h.duyck@intel.com \
--cc=amritha.nambiar@intel.com \
--cc=davem@davemloft.net \
--cc=ecree@solarflare.com \
--cc=jiri@mellanox.com \
--cc=ktkhai@virtuozzo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lirongqing@baidu.com \
--cc=netdev@vger.kernel.org \
--cc=petrm@mellanox.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).