From patchwork Sat May 6 16:04:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13233572 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 745DBC77B7F for ; Sat, 6 May 2023 16:04:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2D936B007B; Sat, 6 May 2023 12:04:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ADE246B007D; Sat, 6 May 2023 12:04:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F3736B007E; Sat, 6 May 2023 12:04:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by kanga.kvack.org (Postfix) with ESMTP id 776506B007B for ; Sat, 6 May 2023 12:04:32 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=behTiREaMc5g42beO1FZ84CdMnER08mqJB7qg1qhoeA=; b=BFolmZ/DBV0UdxhzRYlJ6x+qKv Qx1c/U7tYvCG9w1ZotIRaWd0y5e9iQUR1gUmeszrWARl7xlaef96EHB+jcsxef+z9QpNgk+w7RIop 5ZbSBFaWoe6kw6jwQbAHMSWF7iGYYaaRvUvC+jUtC8CqXyiCpiP5OS1dKqmjVLOOAAUtLrA9PSDml /bLjFi6BgutwYxxZ7F4SKd87pKu8CHd7dDMjwefXbUq+h3uHiBsG36DtGZsSWeGRbBkn+lgawU+O6 TFDG+3oVF/Hh6WfcnL3QC7GJXBjWRCKVe75T4oig9jBPdrpL2HEdim6Yx29OTTrvE74NU8rt3R5lv vJglS7sA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pvKOa-00CYNk-Kf; Sat, 06 May 2023 16:04:28 +0000 From: "Matthew Wilcox (Oracle)" To: Linus Torvalds Cc: "Matthew Wilcox (Oracle)" , Andrew Morton , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Dan Carpenter , syzbot+48011b86c8ea329af1b9@syzkaller.appspotmail.com, Christoph Hellwig Subject: [PATCH] filemap: Handle error return from __filemap_get_folio() Date: Sat, 6 May 2023 17:04:14 +0100 Message-Id: <20230506160415.2992089-1-willy@infradead.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Smatch reports that filemap_fault() was missed in the conversion of __filemap_get_folio() error returns from NULL to ERR_PTR. Fixes: 66dabbb65d67 ("mm: return an ERR_PTR from __filemap_get_folio") Reported-by: Dan Carpenter Reported-by: syzbot+48011b86c8ea329af1b9@syzkaller.appspotmail.com Reported-by: Christoph Hellwig Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Christoph Hellwig Reported-by: Jan Kara Reviewed-by: Jan Kara Reviewed-by: David Howells Tested-by: David Howells Signed-off-by: Andrew Morton Acked-by: Peter Xu Signed-off-by: Peter Xu --- mm/filemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/filemap.c b/mm/filemap.c index a34abfe8c654..b4c9bd368b7e 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3378,7 +3378,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) * re-find the vma and come back and find our hopefully still populated * page. */ - if (folio) + if (!IS_ERR(folio)) folio_put(folio); if (mapping_locked) filemap_invalidate_unlock_shared(mapping);