aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 4d11f9d84666..39aa9d129612 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -428,14 +428,16 @@ int swap_type_of(dev_t device)
428{ 428{
429 int i; 429 int i;
430 430
431 if (!device)
432 return -EINVAL;
433 spin_lock(&swap_lock); 431 spin_lock(&swap_lock);
434 for (i = 0; i < nr_swapfiles; i++) { 432 for (i = 0; i < nr_swapfiles; i++) {
435 struct inode *inode; 433 struct inode *inode;
436 434
437 if (!(swap_info[i].flags & SWP_WRITEOK)) 435 if (!(swap_info[i].flags & SWP_WRITEOK))
438 continue; 436 continue;
437 if (!device) {
438 spin_unlock(&swap_lock);
439 return i;
440 }
439 inode = swap_info->swap_file->f_dentry->d_inode; 441 inode = swap_info->swap_file->f_dentry->d_inode;
440 if (S_ISBLK(inode->i_mode) && 442 if (S_ISBLK(inode->i_mode) &&
441 device == MKDEV(imajor(inode), iminor(inode))) { 443 device == MKDEV(imajor(inode), iminor(inode))) {