kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] usb: gadget: f_fs: check for allocation failure
@ 2016-06-24 12:23 Dan Carpenter
  2016-06-24 20:20 ` Michal Nazarewicz
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-06-24 12:23 UTC (permalink / raw)
  To: kernel-janitors

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>

diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index a91fcb0..5c8429f 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -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);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] usb: gadget: f_fs: check for allocation failure
  2016-06-24 12:23 [patch] usb: gadget: f_fs: check for allocation failure Dan Carpenter
@ 2016-06-24 20:20 ` Michal Nazarewicz
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Nazarewicz @ 2016-06-24 20:20 UTC (permalink / raw)
  To: kernel-janitors

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 1121 bytes --]

On Fri, Jun 24 2016, Dan Carpenter wrote:
> 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>

> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index a91fcb0..5c8429f 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -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);

-- 
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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-24 20:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-24 12:23 [patch] usb: gadget: f_fs: check for allocation failure Dan Carpenter
2016-06-24 20:20 ` Michal Nazarewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).