From: Jens Axboe Date: Fri, 16 Jun 2006 11:02:29 +0000 (+0200) Subject: [PATCH] Fix missing ret assignment in __bio_map_user() error path X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=991721572ef2140c6411894aebefd3377e71a9e7;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [PATCH] Fix missing ret assignment in __bio_map_user() error path If get_user_pages() returns less pages than what we asked for, we jump to out_unmap which will return ERR_PTR(ret). But ret can contain a positive number just smaller than local_nr_pages, so be sure to set it to -EFAULT always. Problem found and diagnosed by Damien Le Moal Signed-off-by: Jens Axboe Signed-off-by: Linus Torvalds --- diff --git a/fs/bio.c b/fs/bio.c index 098c12b2d60a..6a0b9ad8f8c9 100644 --- a/fs/bio.c +++ b/fs/bio.c @@ -654,9 +654,10 @@ static struct bio *__bio_map_user_iov(request_queue_t *q, write_to_vm, 0, &pages[cur_page], NULL); up_read(¤t->mm->mmap_sem); - if (ret < local_nr_pages) + if (ret < local_nr_pages) { + ret = -EFAULT; goto out_unmap; - + } offset = uaddr & ~PAGE_MASK; for (j = cur_page; j < page_limit; j++) {