diff options
author | Al Viro <viro@ftp.linux.org.uk> | 2007-10-29 01:11:28 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-29 10:41:33 -0400 |
commit | 142956af525002c5378e7d91d81a01189841a785 (patch) | |
tree | bcf73cc0e2d56d8d46d470fcedaadf42ae0602bd /drivers/scsi/aacraid | |
parent | 0c7eb2eb800c4afb2205bbaa1bc633eb29082fef (diff) |
fix abuses of ptrdiff_t
Use of ptrdiff_t in places like
- if (!access_ok(VERIFY_WRITE, u_tmp->rx_buf, u_tmp->len))
+ if (!access_ok(VERIFY_WRITE, (u8 __user *)
+ (ptrdiff_t) u_tmp->rx_buf,
+ u_tmp->len))
is wrong; for one thing, it's a bad C (it's what uintptr_t is for; in general
we are not even promised that ptrdiff_t is large enough to hold a pointer,
just enough to hold a difference between two pointers within the same object).
For another, it confuses the fsck out of sparse.
Use unsigned long or uintptr_t instead. There are several places misusing
ptrdiff_t; fixed.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/scsi/aacraid')
-rw-r--r-- | drivers/scsi/aacraid/commctrl.c | 12 | ||||
-rw-r--r-- | drivers/scsi/aacraid/comminit.c | 2 | ||||
-rw-r--r-- | drivers/scsi/aacraid/dpcsup.c | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index 72b0393b4596..1e6d7a9c75bf 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c | |||
@@ -391,7 +391,7 @@ static int close_getadapter_fib(struct aac_dev * dev, void __user *arg) | |||
391 | /* | 391 | /* |
392 | * Extract the fibctx from the input parameters | 392 | * Extract the fibctx from the input parameters |
393 | */ | 393 | */ |
394 | if (fibctx->unique == (u32)(ptrdiff_t)arg) /* We found a winner */ | 394 | if (fibctx->unique == (u32)(uintptr_t)arg) /* We found a winner */ |
395 | break; | 395 | break; |
396 | entry = entry->next; | 396 | entry = entry->next; |
397 | fibctx = NULL; | 397 | fibctx = NULL; |
@@ -590,7 +590,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
590 | } | 590 | } |
591 | addr = (u64)upsg->sg[i].addr[0]; | 591 | addr = (u64)upsg->sg[i].addr[0]; |
592 | addr += ((u64)upsg->sg[i].addr[1]) << 32; | 592 | addr += ((u64)upsg->sg[i].addr[1]) << 32; |
593 | sg_user[i] = (void __user *)(ptrdiff_t)addr; | 593 | sg_user[i] = (void __user *)(uintptr_t)addr; |
594 | sg_list[i] = p; // save so we can clean up later | 594 | sg_list[i] = p; // save so we can clean up later |
595 | sg_indx = i; | 595 | sg_indx = i; |
596 | 596 | ||
@@ -633,7 +633,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
633 | rcode = -ENOMEM; | 633 | rcode = -ENOMEM; |
634 | goto cleanup; | 634 | goto cleanup; |
635 | } | 635 | } |
636 | sg_user[i] = (void __user *)(ptrdiff_t)usg->sg[i].addr; | 636 | sg_user[i] = (void __user *)(uintptr_t)usg->sg[i].addr; |
637 | sg_list[i] = p; // save so we can clean up later | 637 | sg_list[i] = p; // save so we can clean up later |
638 | sg_indx = i; | 638 | sg_indx = i; |
639 | 639 | ||
@@ -664,7 +664,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
664 | if (actual_fibsize64 == fibsize) { | 664 | if (actual_fibsize64 == fibsize) { |
665 | struct user_sgmap64* usg = (struct user_sgmap64 *)upsg; | 665 | struct user_sgmap64* usg = (struct user_sgmap64 *)upsg; |
666 | for (i = 0; i < upsg->count; i++) { | 666 | for (i = 0; i < upsg->count; i++) { |
667 | u64 addr; | 667 | uintptr_t addr; |
668 | void* p; | 668 | void* p; |
669 | /* Does this really need to be GFP_DMA? */ | 669 | /* Does this really need to be GFP_DMA? */ |
670 | p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA); | 670 | p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA); |
@@ -676,7 +676,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
676 | } | 676 | } |
677 | addr = (u64)usg->sg[i].addr[0]; | 677 | addr = (u64)usg->sg[i].addr[0]; |
678 | addr += ((u64)usg->sg[i].addr[1]) << 32; | 678 | addr += ((u64)usg->sg[i].addr[1]) << 32; |
679 | sg_user[i] = (void __user *)(ptrdiff_t)addr; | 679 | sg_user[i] = (void __user *)addr; |
680 | sg_list[i] = p; // save so we can clean up later | 680 | sg_list[i] = p; // save so we can clean up later |
681 | sg_indx = i; | 681 | sg_indx = i; |
682 | 682 | ||
@@ -704,7 +704,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
704 | rcode = -ENOMEM; | 704 | rcode = -ENOMEM; |
705 | goto cleanup; | 705 | goto cleanup; |
706 | } | 706 | } |
707 | sg_user[i] = (void __user *)(ptrdiff_t)upsg->sg[i].addr; | 707 | sg_user[i] = (void __user *)(uintptr_t)upsg->sg[i].addr; |
708 | sg_list[i] = p; // save so we can clean up later | 708 | sg_list[i] = p; // save so we can clean up later |
709 | sg_indx = i; | 709 | sg_indx = i; |
710 | 710 | ||
diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 3009ad8c4073..8736813a0296 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c | |||
@@ -110,7 +110,7 @@ static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long co | |||
110 | /* | 110 | /* |
111 | * Align the beginning of Headers to commalign | 111 | * Align the beginning of Headers to commalign |
112 | */ | 112 | */ |
113 | align = (commalign - ((ptrdiff_t)(base) & (commalign - 1))); | 113 | align = (commalign - ((uintptr_t)(base) & (commalign - 1))); |
114 | base = base + align; | 114 | base = base + align; |
115 | phys = phys + align; | 115 | phys = phys + align; |
116 | /* | 116 | /* |
diff --git a/drivers/scsi/aacraid/dpcsup.c b/drivers/scsi/aacraid/dpcsup.c index fcd25f7d0bc6..e6032ffc66a6 100644 --- a/drivers/scsi/aacraid/dpcsup.c +++ b/drivers/scsi/aacraid/dpcsup.c | |||
@@ -254,7 +254,7 @@ unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index) | |||
254 | kfree (fib); | 254 | kfree (fib); |
255 | return 1; | 255 | return 1; |
256 | } | 256 | } |
257 | memcpy(hw_fib, (struct hw_fib *)(((ptrdiff_t)(dev->regs.sa)) + | 257 | memcpy(hw_fib, (struct hw_fib *)(((uintptr_t)(dev->regs.sa)) + |
258 | (index & ~0x00000002L)), sizeof(struct hw_fib)); | 258 | (index & ~0x00000002L)), sizeof(struct hw_fib)); |
259 | INIT_LIST_HEAD(&fib->fiblink); | 259 | INIT_LIST_HEAD(&fib->fiblink); |
260 | fib->type = FSAFS_NTC_FIB_CONTEXT; | 260 | fib->type = FSAFS_NTC_FIB_CONTEXT; |