]> git.proxmox.com Git - mirror_zfs-debian.git/commitdiff
Fix panic mounting unformatted zvol
authorNed Bass <bass6@llnl.gov>
Fri, 29 Oct 2010 19:13:52 +0000 (12:13 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 29 Oct 2010 21:46:33 +0000 (14:46 -0700)
On some older kernels, i.e. 2.6.18, zvol_ioctl_by_inode() may get passed a NULL
file pointer if the user tries to mount a zvol without a filesystem on it.
This change adds checks to prevent a null pointer dereference.

Closes #73.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
module/zfs/zvol.c

index 6e929429252a269179a4eae150f981d3c90371f1..b2a08fb437c62a7e4a8160ca1a4f3b06bf7518c7 100644 (file)
@@ -1002,6 +1002,8 @@ static int
 zvol_ioctl_by_inode(struct inode *inode, struct file *file,
                     unsigned int cmd, unsigned long arg)
 {
+       if (file == NULL || inode == NULL)
+               return -EINVAL;
        return zvol_ioctl(inode->i_bdev, file->f_mode, cmd, arg);
 }
 
@@ -1010,6 +1012,8 @@ static long
 zvol_compat_ioctl_by_inode(struct file *file,
                            unsigned int cmd, unsigned long arg)
 {
+       if (file == NULL)
+               return -EINVAL;
        return zvol_compat_ioctl(file->f_dentry->d_inode->i_bdev,
                                 file->f_mode, cmd, arg);
 }