]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
hostfs: fix folio conversion
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 24 Jul 2024 01:14:54 +0000 (18:14 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 24 Jul 2024 16:25:15 +0000 (09:25 -0700)
Commit e3ec0fe944d2 ("hostfs: Convert hostfs_read_folio() to use a
folio") simplified hostfs_read_folio(), but in the process of converting
to using folios natively also mis-used the folio_zero_tail() function
due to the very confusing API of that function.

Very arguably it's folio_zero_tail() API itself that is buggy, since it
would make more sense (and the documentation kind of implies) that the
third argument would be the pointer to the beginning of the folio
buffer.

But no, the third argument to folio_zero_tail() is where we should start
zeroing the tail (even if we already also pass in the offset separately
as the second argument).

So fix the hostfs caller, and we can leave any folio_zero_tail() sanity
cleanup for later.

Reported-and-tested-by: Maciej Żenczykowski <maze@google.com>
Fixes: e3ec0fe944d2 ("hostfs: Convert hostfs_read_folio() to use a folio")
Link: https://lore.kernel.org/all/CANP3RGceNzwdb7w=vPf5=7BCid5HVQDmz1K5kC9JG42+HVAh_g@mail.gmail.com/
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Christian Brauner <brauner@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/hostfs/hostfs_kern.c

index 3eb747d2692467e76255a367932dff4341f3c2bb..2b532670a561d51b1c96f2f47e30ad0b3c585494 100644 (file)
@@ -455,7 +455,7 @@ static int hostfs_read_folio(struct file *file, struct folio *folio)
        if (bytes_read < 0)
                ret = bytes_read;
        else
-               buffer = folio_zero_tail(folio, bytes_read, buffer);
+               buffer = folio_zero_tail(folio, bytes_read, buffer + bytes_read);
        kunmap_local(buffer);
 
        folio_end_read(folio, ret == 0);