DWORD   blkno;
 
                buf = kmalloc(blenByte, GFP_KERNEL);
+               if (buf == NULL)
+                       return USB_STOR_TRANSPORT_ERROR;
 
                result = ENE_LoadBinCode(us, MS_RW_PATTERN);
                if (result != USB_STOR_XFER_GOOD)
                WORD    len, oldphy, newphy;
 
                buf = kmalloc(blenByte, GFP_KERNEL);
+               if (buf == NULL)
+                       return USB_STOR_TRANSPORT_ERROR;
                usb_stor_set_xfer_buf(us, buf, blenByte, srb, FROM_XFER_BUF);
 
                result = ENE_LoadBinCode(us, MS_RW_PATTERN);
 
                return USB_STOR_TRANSPORT_ERROR;
 
        buf = kmalloc(blenByte, GFP_KERNEL);
+       if (buf == NULL)
+               return USB_STOR_TRANSPORT_ERROR;
        result = Media_D_ReadSector(us, bn, blen, buf);
        usb_stor_set_xfer_buf(us, buf, blenByte, srb, TO_XFER_BUF);
        kfree(buf);
                return USB_STOR_TRANSPORT_ERROR;
 
        buf = kmalloc(blenByte, GFP_KERNEL);
+       if (buf == NULL)
+               return USB_STOR_TRANSPORT_ERROR;
        usb_stor_set_xfer_buf(us, buf, blenByte, srb, FROM_XFER_BUF);
        result = Media_D_CopySector(us, bn, blen, buf);
        kfree(buf);