diff options
author | Jens Axboe <axboe@suse.de> | 2006-01-09 08:52:21 -0500 |
---|---|---|
committer | Jens Axboe <axboe@suse.de> | 2006-01-09 08:52:21 -0500 |
commit | 5a57be8d100c67a033ec78f00d5a0cd387da72e9 (patch) | |
tree | f83a6c107c1cb9faae1d287b93766cd5091d8d41 /block | |
parent | 0ea60b5ad8c3630e8f44c443f173d841be7fc701 (diff) |
[BLOCK] scsi_ioctl: file can be NULL from ioctl_by_bdev()
Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'block')
-rw-r--r-- | block/scsi_ioctl.c | 13 |
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) | |||
190 | safe_for_write(GPCMD_SET_STREAMING), | 190 | safe_for_write(GPCMD_SET_STREAMING), |
191 | }; | 191 | }; |
192 | unsigned char type = cmd_type[cmd[0]]; | 192 | unsigned char type = cmd_type[cmd[0]]; |
193 | int has_write_perm = 0; | ||
193 | 194 | ||
194 | /* Anybody who can open the device can do a read-safe command */ | 195 | /* Anybody who can open the device can do a read-safe command */ |
195 | if (type & CMD_READ_SAFE) | 196 | if (type & CMD_READ_SAFE) |
196 | return 0; | 197 | return 0; |
197 | 198 | ||
199 | /* | ||
200 | * file can be NULL from ioctl_by_bdev()... | ||
201 | */ | ||
202 | if (file) | ||
203 | has_write_perm = file->f_mode & FMODE_WRITE; | ||
204 | |||
198 | /* Write-safe commands just require a writable open.. */ | 205 | /* Write-safe commands just require a writable open.. */ |
199 | if (type & CMD_WRITE_SAFE) { | 206 | if ((type & CMD_WRITE_SAFE) && has_write_perm) |
200 | if (file->f_mode & FMODE_WRITE) | 207 | return 0; |
201 | return 0; | ||
202 | } | ||
203 | 208 | ||
204 | /* And root can do any command.. */ | 209 | /* And root can do any command.. */ |
205 | if (capable(CAP_SYS_RAWIO)) | 210 | if (capable(CAP_SYS_RAWIO)) |