mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
staging: keucr: check kmalloc() return value
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>
This commit is contained in:
parent
83ef41f085
commit
b1f5f54e91
3 changed files with 10 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue