[86/90] SCSI: megaraid_sas: fix 64 bit sense pointer truncation

Greg KH
2009-12-11T04:42:45Z

[-- Attachment #1: scsi-megaraid_sas-fix-64-bit-sense-pointer-truncation.patch --]
[-- Type: text/plain, Size: 1556 bytes --]

2.6.31-stable review patch. If anyone has any objections, please let us know.

------------------
From: Yang, Bo <Bo.Yang@lsi.com>

commit 7b2519afa1abd1b9f63aa1e90879307842422dae upstream.

The current sense pointer is cast to a u32 pointer, which can truncate
on 64 bits. Fix by using unsigned long instead.

Signed-off-by Bo Yang<bo.yang@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
drivers/scsi/megaraid/megaraid_sas.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/scsi/megaraid/megaraid_sas.c
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -3032,7 +3032,7 @@ megasas_mgmt_fw_ioctl(struct megasas_ins
int error = 0, i;
void *sense = NULL;
dma_addr_t sense_handle;
- u32 *sense_ptr;
+ unsigned long *sense_ptr;

memset(kbuff_arr, 0, sizeof(kbuff_arr));

@@ -3109,7 +3109,7 @@ megasas_mgmt_fw_ioctl(struct megasas_ins
}

sense_ptr =
- (u32 *) ((unsigned long)cmd->frame + ioc->sense_off);
+ (unsigned long *) ((unsigned long)cmd->frame + ioc->sense_off);
*sense_ptr = sense_handle;
}

@@ -3140,8 +3140,8 @@ megasas_mgmt_fw_ioctl(struct megasas_ins
* sense_ptr points to the location that has the user
* sense buffer address
*/
- sense_ptr = (u32 *) ((unsigned long)ioc->frame.raw +
- ioc->sense_off);
+ sense_ptr = (unsigned long *) ((unsigned long)ioc->frame.raw +
+ ioc->sense_off);

if (copy_to_user((void __user *)((unsigned long)(*sense_ptr)),
sense, ioc->sense_len)) {