From: Konstantin Taranov <kotaranov@linux.microsoft.com>
To: shirazsaleem@microsoft.com, kotaranov@microsoft.com,
pabeni@redhat.com, haiyangz@microsoft.com, kys@microsoft.com,
edumazet@google.com, kuba@kernel.org, davem@davemloft.net,
decui@microsoft.com, wei.liu@kernel.org, longli@microsoft.com,
jgg@ziepe.ca, leon@kernel.org
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org
Subject: [PATCH net] net/mana: Fix auxiliary device double-delete race
Date: Mon, 9 Mar 2026 10:24:15 -0700 [thread overview]
Message-ID: <20260309172415.688342-1-kotaranov@linux.microsoft.com> (raw)
From: Shiraz Saleem <shirazsaleem@microsoft.com>
Make remove_adev() safe to call concurrently from the service reset
and PCI eject paths by using xchg() to atomically claim the adev
pointer. This prevents double auxiliary_device_delete/uninit when
hv_eject_device_work races with the service reset workqueue.
Fixes: 505cc26bcae0 ("net: mana: Add support for auxiliary device servicing events")
Signed-off-by: Shiraz Saleem <shirazsaleem@microsoft.com>
Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com>
---
drivers/net/ethernet/microsoft/mana/mana_en.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index 9b5a72a..c45a66e 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -3402,14 +3402,18 @@ static void adev_release(struct device *dev)
static void remove_adev(struct gdma_dev *gd)
{
- struct auxiliary_device *adev = gd->adev;
- int id = adev->id;
+ struct auxiliary_device *adev = xchg(&gd->adev, NULL);
+ int id;
+
+ if (!adev)
+ return;
+
+ id = adev->id;
auxiliary_device_delete(adev);
auxiliary_device_uninit(adev);
mana_adev_idx_free(id);
- gd->adev = NULL;
}
static int add_adev(struct gdma_dev *gd, const char *name)
@@ -3473,7 +3477,7 @@ static void mana_rdma_service_handle(struct work_struct *work)
switch (serv_work->event) {
case GDMA_SERVICE_TYPE_RDMA_SUSPEND:
- if (!gd->adev || gd->is_suspended)
+ if (gd->is_suspended)
break;
remove_adev(gd);
@@ -3676,8 +3680,7 @@ void mana_remove(struct gdma_dev *gd, bool suspending)
cancel_delayed_work_sync(&ac->gf_stats_work);
/* adev currently doesn't support suspending, always remove it */
- if (gd->adev)
- remove_adev(gd);
+ remove_adev(gd);
for (i = 0; i < ac->num_ports; i++) {
ndev = ac->ports[i];
@@ -3764,8 +3767,7 @@ void mana_rdma_remove(struct gdma_dev *gd)
WRITE_ONCE(gd->rdma_teardown, true);
flush_workqueue(gc->service_wq);
- if (gd->adev)
- remove_adev(gd);
+ remove_adev(gd);
mana_gd_deregister_device(gd);
}
--
2.43.0
next reply other threads:[~2026-03-09 17:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 17:24 Konstantin Taranov [this message]
2026-03-11 17:03 ` [PATCH net] net/mana: Fix auxiliary device double-delete race Simon Horman
2026-03-11 23:38 ` Long Li
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=20260309172415.688342-1-kotaranov@linux.microsoft.com \
--to=kotaranov@linux.microsoft.com \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=edumazet@google.com \
--cc=haiyangz@microsoft.com \
--cc=jgg@ziepe.ca \
--cc=kotaranov@microsoft.com \
--cc=kuba@kernel.org \
--cc=kys@microsoft.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shirazsaleem@microsoft.com \
--cc=wei.liu@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.