]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[SCSI] arcmsr: fix message allocation
authorDaniel Drake <dsd@gentoo.org>
Wed, 20 Feb 2008 13:29:05 +0000 (13:29 +0000)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Fri, 22 Feb 2008 15:08:13 +0000 (09:08 -0600)
arcmsr_iop_message_xfer() is called from atomic context under the
queuecommand scsi_host_template handler. James Bottomley pointed out
that the current GFP_KERNEL|GFP_DMA flags are wrong: firstly we are in
atomic context, secondly this memory is not used for DMA.
Also removed some unneeded casts.

Signed-off-by: Daniel Drake <dsd@gentoo.org>
Cc: Nick Cheng <nick.cheng@areca.com.tw>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
drivers/scsi/arcmsr/arcmsr_hba.c

index 4f9ff32cfed09592c91bf4e92b1103803c90718c..f91f79c8007d50f69d4b99f22fdc711d970ad1b2 100644 (file)
@@ -1387,18 +1387,16 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, \
        switch(controlcode) {
 
        case ARCMSR_MESSAGE_READ_RQBUFFER: {
-               unsigned long *ver_addr;
+               unsigned char *ver_addr;
                uint8_t *pQbuffer, *ptmpQbuffer;
                int32_t allxfer_len = 0;
-               void *tmp;
 
-               tmp = kmalloc(1032, GFP_KERNEL|GFP_DMA);
-               ver_addr = (unsigned long *)tmp;
-               if (!tmp) {
+               ver_addr = kmalloc(1032, GFP_ATOMIC);
+               if (!ver_addr) {
                        retvalue = ARCMSR_MESSAGE_FAIL;
                        goto message_out;
                }
-               ptmpQbuffer = (uint8_t *) ver_addr;
+               ptmpQbuffer = ver_addr;
                while ((acb->rqbuf_firstindex != acb->rqbuf_lastindex)
                        && (allxfer_len < 1031)) {
                        pQbuffer = &acb->rqbuffer[acb->rqbuf_firstindex];
@@ -1427,26 +1425,24 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, \
                        }
                        arcmsr_iop_message_read(acb);
                }
-               memcpy(pcmdmessagefld->messagedatabuffer, (uint8_t *)ver_addr, allxfer_len);
+               memcpy(pcmdmessagefld->messagedatabuffer, ver_addr, allxfer_len);
                pcmdmessagefld->cmdmessage.Length = allxfer_len;
                pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK;
-               kfree(tmp);
+               kfree(ver_addr);
                }
                break;
 
        case ARCMSR_MESSAGE_WRITE_WQBUFFER: {
-               unsigned long *ver_addr;
+               unsigned char *ver_addr;
                int32_t my_empty_len, user_len, wqbuf_firstindex, wqbuf_lastindex;
                uint8_t *pQbuffer, *ptmpuserbuffer;
-               void *tmp;
 
-               tmp = kmalloc(1032, GFP_KERNEL|GFP_DMA);
-               ver_addr = (unsigned long *)tmp;
-               if (!tmp) {
+               ver_addr = kmalloc(1032, GFP_ATOMIC);
+               if (!ver_addr) {
                        retvalue = ARCMSR_MESSAGE_FAIL;
                        goto message_out;
                }
-               ptmpuserbuffer = (uint8_t *)ver_addr;
+               ptmpuserbuffer = ver_addr;
                user_len = pcmdmessagefld->cmdmessage.Length;
                memcpy(ptmpuserbuffer, pcmdmessagefld->messagedatabuffer, user_len);
                wqbuf_lastindex = acb->wqbuf_lastindex;
@@ -1492,7 +1488,7 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, \
                                retvalue = ARCMSR_MESSAGE_FAIL;
                        }
                        }
-                       kfree(tmp);
+                       kfree(ver_addr);
                }
                break;