unsigned char *swap_map = NULL;
struct page *page = NULL;
struct inode *inode = NULL;
- int did_down = 0;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
} else if (S_ISREG(inode->i_mode)) {
p->bdev = inode->i_sb->s_bdev;
mutex_lock(&inode->i_mutex);
- did_down = 1;
if (IS_SWAPFILE(inode)) {
error = -EBUSY;
goto bad_swap;
spin_unlock(&swap_lock);
vfree(swap_map);
if (swap_file) {
- if (did_down) {
+ if (inode && S_ISREG(inode->i_mode))
mutex_unlock(&inode->i_mutex);
- did_down = 0;
- }
filp_close(swap_file, NULL);
}
out:
}
if (name)
putname(name);
- if (did_down) {
+ if (inode && S_ISREG(inode->i_mode)) {
if (!error)
inode->i_flags |= S_SWAPFILE;
mutex_unlock(&inode->i_mutex);