From: Jiang Liu <liuj97@gmail.com>
To: Alex Williamson <alex.williamson@redhat.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiang Liu <jiang.liu@huawei.com>,
Joerg Roedel <joerg.roedel@amd.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Hanjun Guo <guohanjun@huawei.com>
Subject: [PATCH v2 2/3] VFIO: use ACCESS_ONCE() to guard access to dev->driver
Date: Fri, 16 Nov 2012 00:43:17 +0800 [thread overview]
Message-ID: <1352997798-18891-2-git-send-email-jiang.liu@huawei.com> (raw)
In-Reply-To: <1352997798-18891-1-git-send-email-jiang.liu@huawei.com>
Comments from dev_driver_string(),
/* dev->driver can change to NULL underneath us because of unbinding,
* so be careful about accessing it.
*/
So use ACCESS_ONCE() to guard access to dev->driver field.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
---
drivers/vfio/vfio.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index 3359ec2..0090212 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -465,8 +465,9 @@ static int vfio_dev_viable(struct device *dev, void *data)
{
struct vfio_group *group = data;
struct vfio_device *device;
+ struct device_driver *drv = ACCESS_ONCE(dev->driver);
- if (!dev->driver || vfio_whitelisted_driver(dev->driver))
+ if (!drv || vfio_whitelisted_driver(drv))
return 0;
device = vfio_group_get_device(group, dev);
--
1.7.9.5
next prev parent reply other threads:[~2012-11-15 16:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-15 16:43 [PATCH v2 1/3] VFIO: unregister IOMMU notifier on error recovery path Jiang Liu
2012-11-15 16:43 ` Jiang Liu [this message]
2012-11-15 16:43 ` [PATCH v2 3/3] VFIO: fix out of order labels for error recovery in vfio_pci_init() Jiang Liu
2012-11-15 18:31 ` [PATCH v2 1/3] VFIO: unregister IOMMU notifier on error recovery path Alex Williamson
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=1352997798-18891-2-git-send-email-jiang.liu@huawei.com \
--to=liuj97@gmail.com \
--cc=alex.williamson@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=guohanjun@huawei.com \
--cc=jiang.liu@huawei.com \
--cc=joerg.roedel@amd.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@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