usb: gadget: f_fs: check for allocation failure
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 24 Jun 2016 12:23:16 +0000 (15:23 +0300)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Wed, 29 Jun 2016 08:13:33 +0000 (11:13 +0300)
Return -ENOMEM if kmalloc() fails.

Fixes: 9353afbbfa7b ('usb: gadget: f_fs: buffer data from ‘oversized’ OUT requests')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/function/f_fs.c

index a91fcb0475b268a55d704ece7267b63e92225924..5c8429f23a892782febdb3c650efa8c168705227 100644 (file)
@@ -775,6 +775,8 @@ static ssize_t __ffs_epfile_read_data(struct ffs_epfile *epfile,
 
        data_len -= ret;
        buf = kmalloc(sizeof(*buf) + data_len, GFP_KERNEL);
+       if (!buf)
+               return -ENOMEM;
        buf->length = data_len;
        buf->data = buf->storage;
        memcpy(buf->storage, data + ret, data_len);