]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usb: gadget: f_fs: data_len used before properly set
authorFei Yang <fei.yang@intel.com>
Wed, 12 Jun 2019 22:13:26 +0000 (15:13 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 14 Jul 2019 06:09:49 +0000 (08:09 +0200)
commit5b5a979c8fb2d5d85789c577478762d6d5c99fe9
treee4438f99705adc06984aa349ff0a9c90aa54c68a
parentcae928691200cbe65da1b31d92472f50abe48a14
usb: gadget: f_fs: data_len used before properly set

commit 4833a94eb383f5b22775077ff92ddaae90440921 upstream.

The following line of code in function ffs_epfile_io is trying to set
flag io_data->use_sg in case buffer required is larger than one page.

    io_data->use_sg = gadget->sg_supported && data_len > PAGE_SIZE;

However at this point of time the variable data_len has not been set
to the proper buffer size yet. The consequence is that io_data->use_sg
is always set regardless what buffer size really is, because the condition
(data_len > PAGE_SIZE) is effectively an unsigned comparison between
-EINVAL and PAGE_SIZE which would always result in TRUE.

Fixes: 772a7a724f69 ("usb: gadget: f_fs: Allow scatter-gather buffers")
Signed-off-by: Fei Yang <fei.yang@intel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/f_fs.c