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>
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);
}
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);
}