summaryrefslogtreecommitdiff
path: root/block/scsi_ioctl.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@suse.de>2006-01-09 14:52:21 +0100
committerJens Axboe <axboe@suse.de>2006-01-09 14:52:21 +0100
commit5a57be8d100c67a033ec78f00d5a0cd387da72e9 (patch)
treef83a6c107c1cb9faae1d287b93766cd5091d8d41 /block/scsi_ioctl.c
parent0ea60b5ad8c3630e8f44c443f173d841be7fc701 (diff)
downloadlwn-5a57be8d100c67a033ec78f00d5a0cd387da72e9.tar.gz
lwn-5a57be8d100c67a033ec78f00d5a0cd387da72e9.zip
[BLOCK] scsi_ioctl: file can be NULL from ioctl_by_bdev()
Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'block/scsi_ioctl.c')
-rw-r--r--block/scsi_ioctl.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index c2ac36dfe4f3..18de84c8ccd8 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -190,16 +190,21 @@ static int verify_command(struct file *file, unsigned char *cmd)
safe_for_write(GPCMD_SET_STREAMING),
};
unsigned char type = cmd_type[cmd[0]];
+ int has_write_perm = 0;
/* Anybody who can open the device can do a read-safe command */
if (type & CMD_READ_SAFE)
return 0;
+ /*
+ * file can be NULL from ioctl_by_bdev()...
+ */
+ if (file)
+ has_write_perm = file->f_mode & FMODE_WRITE;
+
/* Write-safe commands just require a writable open.. */
- if (type & CMD_WRITE_SAFE) {
- if (file->f_mode & FMODE_WRITE)
- return 0;
- }
+ if ((type & CMD_WRITE_SAFE) && has_write_perm)
+ return 0;
/* And root can do any command.. */
if (capable(CAP_SYS_RAWIO))