Skip to contentSkip to conversation

usb: gadget: f_fs: check for allocation failure

PATCH In review Dan Carpenter 2 participants 2 messages Jun 24, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: gadget: f_fs: check for allocation failure

Return -ENOMEM if kmalloc() fails.

Fixes 9353afbbfa7b ('usb: gadget: f_fs: buffer data from ‘oversized’ OUT requests')
drivers/usb/gadget/function/f_fs.c +2 -0
index a91fcb0..5c8429f 100644
@@ -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);
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dan Carpenter

Return -ENOMEM if kmalloc() fails.

Fixes 9353afbbfa7b ('usb: gadget: f_fs: buffer data from ‘oversized’ OUT requests')
Quoted 13 lines
drivers/usb/gadget/function/f_fs.c +2 -0
index a91fcb0..5c8429f 100644
@@ -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);
Signature · 7 lines
Best regards
ミ�ウ “����86� ナザレヴイツ
«If at first you don’t succeed, give up skydiving»
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html