diff options
author | Dongwoo <dwoo08.lee@samsung.com> | 2018-10-26 10:41:41 +0900 |
---|---|---|
committer | Jaehoon Chung <jh80.chung@samsung.com> | 2019-01-29 11:25:39 +0900 |
commit | badec43b11fb3adb4ea25745c568f2e828ff8669 (patch) | |
tree | 62a390cca8f3ea42ff7efbd0e75cb04026e21314 | |
parent | 8899802798809d394e6350a6b42f3b392e5defdf (diff) | |
download | linux-artik7-badec43b11fb3adb4ea25745c568f2e828ff8669.tar.gz linux-artik7-badec43b11fb3adb4ea25745c568f2e828ff8669.tar.bz2 linux-artik7-badec43b11fb3adb4ea25745c568f2e828ff8669.zip |
LOCAL / usb: gadget: f_fs: Limit data buffer size to a single page
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.
* This is WORKAROUND solution for just use case of sdbd, it should be
reverted when the advanced dma solution is applied to f_fs *
Change-Id: Ib917c3aef2b00a3e00a3d87ca6d6940307038aa1
Signed-off-by: Dongwoo <dwoo08.lee@samsung.com>
-rw-r--r-- | drivers/usb/gadget/function/f_fs.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 4800bb22cdd6..009a776c372a 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -736,6 +736,14 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) return -ESHUTDOWN; } data_len = iov_iter_count(&io_data->data); + + /* + * WORKAROUND: + * 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. |