static int blktap_release(struct inode *inode, struct file *filp)
{
tap_blkif_t *info = filp->private_data;
+ struct mm_struct *mm;
/* check for control device */
if (!info)
info->ring_ok = 0;
smp_wmb();
- mmput(info->mm);
+ mm = xchg(&info->mm, NULL);
+ if (mm)
+ mmput(mm);
info->mm = NULL;
kfree(info->foreign_map.map);
info->foreign_map.map = NULL;
INVALID_P2M_ENTRY);
}
- if (khandle->user != INVALID_GRANT_HANDLE) {
+ if (mm != NULL && khandle->user != INVALID_GRANT_HANDLE) {
BUG_ON(xen_feature(XENFEAT_auto_translated_physmap));
if (!locked++)
down_write(&mm->mmap_sem);
int tap_blkif_schedule(void *arg)
{
blkif_t *blkif = arg;
+ tap_blkif_t *info;
blkif_get(blkif);
printk(KERN_DEBUG "%s: exiting\n", current->comm);
blkif->xenblkd = NULL;
+ info = tapfds[blkif->dev_num];
blkif_put(blkif);
+ if (info) {
+ struct mm_struct *mm = xchg(&info->mm, NULL);
+
+ if (mm)
+ mmput(mm);
+ }
+
return 0;
}