lkml.org 
[lkml]   [2012]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 6/6] VFIO: use ACCESS_ONCE() to guard access to dev->driver
Date

From: Jiang Liu <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 18714b9..f158e42 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -520,8 +520,9 @@ static bool vfio_whitelisted_driver(struct device_driver *drv)
static int vfio_dev_viable(struct device *dev, void *data)
{
struct vfio_device_driver *driver;
+ struct device_driver *drv = ACCESS_ONCE(dev->driver);

- if (!dev->driver || vfio_whitelisted_driver(dev->driver))
+ if (!drv || vfio_whitelisted_driver(drv))
return 0;

mutex_lock(&vfio.device_drivers_lock);
--
1.7.9.5


\
 
 \ /
  Last update: 2012-11-10 15:21    [W:0.082 / U:0.488 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site