staging: keucr: check kmalloc() return value
authorVasiliy Kulikov <segooon@gmail.com>
Sun, 19 Sep 2010 07:36:23 +0000 (11:36 +0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 21 Sep 2010 00:03:41 +0000 (17:03 -0700)
kmalloc() may fail, if so return error code.

Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/keucr/init.c
drivers/staging/keucr/msscsi.c
drivers/staging/keucr/smscsi.c

index 2ae129bfb608652d5aab5c81f809e91b3a1b18ff..1934805844f21247239e047e4093f4e47d634680 100644 (file)
@@ -300,6 +300,8 @@ int ENE_LoadBinCode(struct us_data *us, BYTE flag)
                return USB_STOR_TRANSPORT_GOOD;
 
        buf = kmalloc(0x800, GFP_KERNEL);
+       if (buf == NULL)
+               return USB_STOR_TRANSPORT_ERROR;
        switch ( flag )
        {
                // For SD
index b908a238396639e7398cc2dd0c9aff7c77e76d21..ad0c5c629935013f10b6b919e018806f2ba0ff3d 100644 (file)
@@ -168,6 +168,8 @@ int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
                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)
@@ -271,6 +273,8 @@ int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
                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);
index 43e32c6ded90792724da2e2ae9e2c9a07d4f2dcb..62116869b38aaa67994fbfbbb43f6eb220fa885c 100644 (file)
@@ -145,6 +145,8 @@ int SM_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
                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);
@@ -175,6 +177,8 @@ int SM_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
                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);