Skip to content

Commit

Permalink
VFIO: use ACCESS_ONCE() to guard access to dev->driver
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
  • Loading branch information
Jiang Liu authored and Alex Williamson committed Dec 7, 2012
1 parent 9df7b25 commit de2b3ee
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/vfio/vfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit de2b3ee

Please sign in to comment.