From: ZhangPeng Date: Mon, 4 Nov 2024 12:34:40 +0000 (+0800) Subject: hostfs: Fix the NULL vs IS_ERR() bug for __filemap_get_folio() X-Git-Tag: v6.12.2~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f888356886be46922dba737d65087df607bd1a46;p=thirdparty%2Fkernel%2Fstable.git hostfs: Fix the NULL vs IS_ERR() bug for __filemap_get_folio() [ Upstream commit bed2cc482600296fe04edbc38005ba2851449c10 ] The __filemap_get_folio() function returns error pointers. It never returns NULL. So use IS_ERR() to check it. Fixes: 1da86618bdce ("fs: Convert aops->write_begin to take a folio") Signed-off-by: ZhangPeng Acked-by: Johannes Berg Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 6d1cf2436ead6..084f6ed2dd7a6 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -471,8 +471,8 @@ static int hostfs_write_begin(struct file *file, struct address_space *mapping, *foliop = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN, mapping_gfp_mask(mapping)); - if (!*foliop) - return -ENOMEM; + if (IS_ERR(*foliop)) + return PTR_ERR(*foliop); return 0; }