diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-05 16:30:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-05 16:30:44 -0400 |
commit | 4f7a307dc6e4d8bfeb56f7cf7231b08cb845687c (patch) | |
tree | 3bf90522c87fcb32373cb2a5ff25b1ead33405f5 /drivers/scsi/sg.c | |
parent | fabb5c4e4a474ff0f7d6c1d3466a1b79bbce5f49 (diff) | |
parent | 7297824581755593535fc97d2c8b6c47e2dc2db6 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (87 commits)
[SCSI] fusion: fix domain validation loops
[SCSI] qla2xxx: fix regression on sparc64
[SCSI] modalias for scsi devices
[SCSI] sg: cap reserved_size values at max_sectors
[SCSI] BusLogic: stop using check_region
[SCSI] tgt: fix rdma transfer bugs
[SCSI] aacraid: fix aacraid not finding device
[SCSI] aacraid: Correct SMC products in aacraid.txt
[SCSI] scsi_error.c: Add EH Start Unit retry
[SCSI] aacraid: [Fastboot] Panics for AACRAID driver during 'insmod' for kexec test.
[SCSI] ipr: Driver version to 2.3.2
[SCSI] ipr: Faster sg list fetch
[SCSI] ipr: Return better qc_issue errors
[SCSI] ipr: Disrupt device error
[SCSI] ipr: Improve async error logging level control
[SCSI] ipr: PCI unblock config access fix
[SCSI] ipr: Fix for oops following SATA request sense
[SCSI] ipr: Log error for SAS dual path switch
[SCSI] ipr: Enable logging of debug error data for all devices
[SCSI] ipr: Add new PCI-E IDs to device table
...
Diffstat (limited to 'drivers/scsi/sg.c')
-rw-r--r-- | drivers/scsi/sg.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 81e3bc7b02a1..570977cf9efb 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -917,6 +917,8 @@ sg_ioctl(struct inode *inode, struct file *filp, | |||
917 | return result; | 917 | return result; |
918 | if (val < 0) | 918 | if (val < 0) |
919 | return -EINVAL; | 919 | return -EINVAL; |
920 | val = min_t(int, val, | ||
921 | sdp->device->request_queue->max_sectors * 512); | ||
920 | if (val != sfp->reserve.bufflen) { | 922 | if (val != sfp->reserve.bufflen) { |
921 | if (sg_res_in_use(sfp) || sfp->mmap_called) | 923 | if (sg_res_in_use(sfp) || sfp->mmap_called) |
922 | return -EBUSY; | 924 | return -EBUSY; |
@@ -925,7 +927,8 @@ sg_ioctl(struct inode *inode, struct file *filp, | |||
925 | } | 927 | } |
926 | return 0; | 928 | return 0; |
927 | case SG_GET_RESERVED_SIZE: | 929 | case SG_GET_RESERVED_SIZE: |
928 | val = (int) sfp->reserve.bufflen; | 930 | val = min_t(int, sfp->reserve.bufflen, |
931 | sdp->device->request_queue->max_sectors * 512); | ||
929 | return put_user(val, ip); | 932 | return put_user(val, ip); |
930 | case SG_SET_COMMAND_Q: | 933 | case SG_SET_COMMAND_Q: |
931 | result = get_user(val, ip); | 934 | result = get_user(val, ip); |
@@ -1061,6 +1064,9 @@ sg_ioctl(struct inode *inode, struct file *filp, | |||
1061 | if (sdp->detached) | 1064 | if (sdp->detached) |
1062 | return -ENODEV; | 1065 | return -ENODEV; |
1063 | return scsi_ioctl(sdp->device, cmd_in, p); | 1066 | return scsi_ioctl(sdp->device, cmd_in, p); |
1067 | case BLKSECTGET: | ||
1068 | return put_user(sdp->device->request_queue->max_sectors * 512, | ||
1069 | ip); | ||
1064 | default: | 1070 | default: |
1065 | if (read_only) | 1071 | if (read_only) |
1066 | return -EPERM; /* don't know so take safe approach */ | 1072 | return -EPERM; /* don't know so take safe approach */ |
@@ -2339,6 +2345,7 @@ sg_add_sfp(Sg_device * sdp, int dev) | |||
2339 | { | 2345 | { |
2340 | Sg_fd *sfp; | 2346 | Sg_fd *sfp; |
2341 | unsigned long iflags; | 2347 | unsigned long iflags; |
2348 | int bufflen; | ||
2342 | 2349 | ||
2343 | sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN); | 2350 | sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN); |
2344 | if (!sfp) | 2351 | if (!sfp) |
@@ -2369,7 +2376,9 @@ sg_add_sfp(Sg_device * sdp, int dev) | |||
2369 | if (unlikely(sg_big_buff != def_reserved_size)) | 2376 | if (unlikely(sg_big_buff != def_reserved_size)) |
2370 | sg_big_buff = def_reserved_size; | 2377 | sg_big_buff = def_reserved_size; |
2371 | 2378 | ||
2372 | sg_build_reserve(sfp, sg_big_buff); | 2379 | bufflen = min_t(int, sg_big_buff, |
2380 | sdp->device->request_queue->max_sectors * 512); | ||
2381 | sg_build_reserve(sfp, bufflen); | ||
2373 | SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: bufflen=%d, k_use_sg=%d\n", | 2382 | SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: bufflen=%d, k_use_sg=%d\n", |
2374 | sfp->reserve.bufflen, sfp->reserve.k_use_sg)); | 2383 | sfp->reserve.bufflen, sfp->reserve.k_use_sg)); |
2375 | return sfp; | 2384 | return sfp; |