diff options
author | Dongwoo Lee <dwoo08.lee@samsung.com> | 2020-05-08 15:30:40 +0900 |
---|---|---|
committer | Dongwoo Lee <dwoo08.lee@samsung.com> | 2020-05-08 16:15:52 +0900 |
commit | 2451064bfbff9dfd3729e12fe085e289985c65d4 (patch) | |
tree | d4dc15706a489595986a7828ff9b943288fe55e6 | |
parent | 1e258d74875f0101cade9cfb0f42b95631c77e8b (diff) | |
download | linux-4.9-exynos9110-2451064bfbff9dfd3729e12fe085e289985c65d4.tar.gz linux-4.9-exynos9110-2451064bfbff9dfd3729e12fe085e289985c65d4.tar.bz2 linux-4.9-exynos9110-2451064bfbff9dfd3729e12fe085e289985c65d4.zip |
usb: gadget: f_fs: Limit data buffer size to a single pagesubmit/tizen/20200508.072818accepted/tizen/unified/20200510.220449
Large size request from sdbd usually causes memory allocation failure
in case of memory shortage. The failure is not handled by sdbd
properly and thus it makes sdbd a hung state. To prevent this
situation, this patch limits data buffer size to a single page so as
to guarantee memory allocation success.
Change-Id: I4eada6c8beca337cf93182b6d860209cc80d044d
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
-rw-r--r-- | drivers/usb/gadget/function/f_fs.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 59c69db43041..b26b607eb0f2 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -940,6 +940,13 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) goto error_lock; } data_len = iov_iter_count(&io_data->data); + + /* + * To prevent memory allocation failure of big size request, + * limits data buffer size to a single page. + */ + data_len = (data_len > PAGE_SIZE) ? PAGE_SIZE : data_len; + /* * Controller may require buffer size to be aligned to * maxpacketsize of an out endpoint. |