Skip to content

Commit

Permalink
[SCSI] sg direct io/mmap oops, st sync
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Douglas Gilbert authored and James Bottomley committed Sep 5, 2005
1 parent 07542b8 commit deb92b7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/scsi/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static int sg_version_num = 30533; /* 2 digits for each component */

#ifdef CONFIG_SCSI_PROC_FS
#include <linux/proc_fs.h>
static char *sg_version_date = "20050328";
static char *sg_version_date = "20050901";

static int sg_proc_init(void);
static void sg_proc_cleanup(void);
Expand Down Expand Up @@ -1794,12 +1794,12 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages,
unsigned long uaddr, size_t count, int rw,
unsigned long max_pfn)
{
unsigned long end = (uaddr + count + PAGE_SIZE - 1) >> PAGE_SHIFT;
unsigned long start = uaddr >> PAGE_SHIFT;
const int nr_pages = end - start;
int res, i, j;
unsigned int nr_pages;
struct page **pages;

nr_pages = ((uaddr & ~PAGE_MASK) + count + ~PAGE_MASK) >> PAGE_SHIFT;

/* User attempted Overflow! */
if ((uaddr + count) < uaddr)
return -EINVAL;
Expand Down

0 comments on commit deb92b7

Please sign in to comment.