From b1c58213751141f28793e723017d4064893d819a Mon Sep 17 00:00:00 2001 From: Ned Bass Date: Fri, 29 Oct 2010 12:13:52 -0700 Subject: [PATCH] Fix panic mounting unformatted zvol 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 --- module/zfs/zvol.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c index 6e9294292..b2a08fb43 100644 --- a/module/zfs/zvol.c +++ b/module/zfs/zvol.c @@ -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); }