aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-09-01 11:39:21 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-09-04 19:05:16 -0400
commit05a4a33b6d82bc6ec157b0bda409b2708b1fa45f (patch)
treed603ead3c2fe70c412ee399f0530d321a0433f32
parent21cb2559eb510dfbe9b5d0dd31605f44d2cd2891 (diff)
gadget/f_mass_storage: stop messing with the address limit
Instead use kernel_read/write consistently, which also makes sparse happy. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--drivers/usb/gadget/function/f_mass_storage.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index f95bddd6513f..d6bd0244b008 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -686,9 +686,8 @@ static int do_read(struct fsg_common *common)
686 686
687 /* Perform the read */ 687 /* Perform the read */
688 file_offset_tmp = file_offset; 688 file_offset_tmp = file_offset;
689 nread = vfs_read(curlun->filp, 689 nread = kernel_read(curlun->filp, bh->buf, amount,
690 (char __user *)bh->buf, 690 &file_offset_tmp);
691 amount, &file_offset_tmp);
692 VLDBG(curlun, "file read %u @ %llu -> %d\n", amount, 691 VLDBG(curlun, "file read %u @ %llu -> %d\n", amount,
693 (unsigned long long)file_offset, (int)nread); 692 (unsigned long long)file_offset, (int)nread);
694 if (signal_pending(current)) 693 if (signal_pending(current))
@@ -883,8 +882,8 @@ static int do_write(struct fsg_common *common)
883 882
884 /* Perform the write */ 883 /* Perform the write */
885 file_offset_tmp = file_offset; 884 file_offset_tmp = file_offset;
886 nwritten = vfs_write(curlun->filp, (char __user *)bh->buf, 885 nwritten = kernel_write(curlun->filp, bh->buf, amount,
887 amount, &file_offset_tmp); 886 &file_offset_tmp);
888 VLDBG(curlun, "file write %u @ %llu -> %d\n", amount, 887 VLDBG(curlun, "file write %u @ %llu -> %d\n", amount,
889 (unsigned long long)file_offset, (int)nwritten); 888 (unsigned long long)file_offset, (int)nwritten);
890 if (signal_pending(current)) 889 if (signal_pending(current))
@@ -1021,9 +1020,8 @@ static int do_verify(struct fsg_common *common)
1021 1020
1022 /* Perform the read */ 1021 /* Perform the read */
1023 file_offset_tmp = file_offset; 1022 file_offset_tmp = file_offset;
1024 nread = vfs_read(curlun->filp, 1023 nread = kernel_read(curlun->filp, bh->buf, amount,
1025 (char __user *) bh->buf, 1024 &file_offset_tmp);
1026 amount, &file_offset_tmp);
1027 VLDBG(curlun, "file read %u @ %llu -> %d\n", amount, 1025 VLDBG(curlun, "file read %u @ %llu -> %d\n", amount,
1028 (unsigned long long) file_offset, 1026 (unsigned long long) file_offset,
1029 (int) nread); 1027 (int) nread);
@@ -2453,13 +2451,6 @@ static int fsg_main_thread(void *common_)
2453 /* Allow the thread to be frozen */ 2451 /* Allow the thread to be frozen */
2454 set_freezable(); 2452 set_freezable();
2455 2453
2456 /*
2457 * Arrange for userspace references to be interpreted as kernel
2458 * pointers. That way we can pass a kernel pointer to a routine
2459 * that expects a __user pointer and it will work okay.
2460 */
2461 set_fs(get_ds());
2462
2463 /* The main loop */ 2454 /* The main loop */
2464 while (common->state != FSG_STATE_TERMINATED) { 2455 while (common->state != FSG_STATE_TERMINATED) {
2465 if (exception_in_progress(common) || signal_pending(current)) { 2456 if (exception_in_progress(common) || signal_pending(current)) {