diff options
author | Douglas Gilbert <dougg@torque.net> | 2005-09-01 07:50:02 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.(none)> | 2005-09-04 20:46:03 -0400 |
commit | deb92b7ee98e8e580cafaa63bd1edbe6646877bc (patch) | |
tree | d9f5210e78095048a2ba8a0cd90b19116d1a894f /drivers/scsi/sg.c | |
parent | 07542b832309b93a2741cd162a391ab909f66438 (diff) |
[SCSI] sg direct io/mmap oops, st sync
This patch adopts the same solution as proposed by Kai M. in
a post titled: "[PATCH] SCSI tape signed/unsigned fix".
The fix is in a function that the sg driver borrowed from
the st driver so its maintenance is a little easier if
the functions remain the same after the fix.
- change nr_pages type from unsigned to signed so errors
from get_user_pages() call are properly handled
Signed-off-by: Douglas Gilbert <dougg@torque.net>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/sg.c')
-rw-r--r-- | drivers/scsi/sg.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 14fb179b3842..616c3f3e62fc 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -61,7 +61,7 @@ static int sg_version_num = 30533; /* 2 digits for each component */ | |||
61 | 61 | ||
62 | #ifdef CONFIG_SCSI_PROC_FS | 62 | #ifdef CONFIG_SCSI_PROC_FS |
63 | #include <linux/proc_fs.h> | 63 | #include <linux/proc_fs.h> |
64 | static char *sg_version_date = "20050328"; | 64 | static char *sg_version_date = "20050901"; |
65 | 65 | ||
66 | static int sg_proc_init(void); | 66 | static int sg_proc_init(void); |
67 | static void sg_proc_cleanup(void); | 67 | static void sg_proc_cleanup(void); |
@@ -1794,12 +1794,12 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, | |||
1794 | unsigned long uaddr, size_t count, int rw, | 1794 | unsigned long uaddr, size_t count, int rw, |
1795 | unsigned long max_pfn) | 1795 | unsigned long max_pfn) |
1796 | { | 1796 | { |
1797 | unsigned long end = (uaddr + count + PAGE_SIZE - 1) >> PAGE_SHIFT; | ||
1798 | unsigned long start = uaddr >> PAGE_SHIFT; | ||
1799 | const int nr_pages = end - start; | ||
1797 | int res, i, j; | 1800 | int res, i, j; |
1798 | unsigned int nr_pages; | ||
1799 | struct page **pages; | 1801 | struct page **pages; |
1800 | 1802 | ||
1801 | nr_pages = ((uaddr & ~PAGE_MASK) + count + ~PAGE_MASK) >> PAGE_SHIFT; | ||
1802 | |||
1803 | /* User attempted Overflow! */ | 1803 | /* User attempted Overflow! */ |
1804 | if ((uaddr + count) < uaddr) | 1804 | if ((uaddr + count) < uaddr) |
1805 | return -EINVAL; | 1805 | return -EINVAL; |