From patchwork Tue Jul 16 02:25:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ma Ke X-Patchwork-Id: 13733989 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 73272C3DA4B for ; Tue, 16 Jul 2024 02:25:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AFA6F6B008A; Mon, 15 Jul 2024 22:25:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AAA706B0092; Mon, 15 Jul 2024 22:25:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9712F6B0093; Mon, 15 Jul 2024 22:25:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 785666B008A for ; Mon, 15 Jul 2024 22:25:40 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E190E120311 for ; Tue, 16 Jul 2024 02:25:39 +0000 (UTC) X-FDA: 82344024798.22.2309594 Received: from cstnet.cn (smtp84.cstnet.cn [159.226.251.84]) by imf14.hostedemail.com (Postfix) with ESMTP id 48898100010 for ; Tue, 16 Jul 2024 02:25:35 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of make24@iscas.ac.cn designates 159.226.251.84 as permitted sender) smtp.mailfrom=make24@iscas.ac.cn; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721096719; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=MyANYL7EWVGCGEVQkKcX11SQbDPxyqNcpPQ0Vvx6Djo=; b=EgXXdDpuahCC2Owbg0v21mXt8288v5xtpS1xQ4MqtxxuXR1wHtiIyyLm8Y8tOUqzI58zUO NGLh1pvVau7N9mrDKxrv7v2S0izf5SQh6W++B8ftqExMZEgXb3zmX7O6BTG39gO0/m0BFW NzijU3mwshkTV3J4f8BhqSBdWqThw0Y= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of make24@iscas.ac.cn designates 159.226.251.84 as permitted sender) smtp.mailfrom=make24@iscas.ac.cn; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721096719; a=rsa-sha256; cv=none; b=y0s/3HPNl8ZElF6mLJs6bhgzHCR9/AZ+5wwiOKX49KXDAr6tm0RdfZGTyKdLC1ZjQ9mCKD Drl6c7fRJAqFos3F8hErkuS2uCZavxPi2kSnz8TliF3vB3x9SubpBXtdVxlTQrzXfLheMk EZBghAyXKkRgBU5sAtt2ST2EuiEkZ+4= Received: from icess-ProLiant-DL380-Gen10.. (unknown [183.174.60.14]) by APP-05 (Coremail) with SMTP id zQCowACnr+cP2pVmVeKLAw--.25774S2; Tue, 16 Jul 2024 10:25:26 +0800 (CST) From: Ma Ke To: willy@infradead.org, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ma Ke Subject: [PATCH] filemap: fix error pointer dereference in filemap_fault() Date: Tue, 16 Jul 2024 10:25:18 +0800 Message-Id: <20240716022518.430237-1-make24@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: zQCowACnr+cP2pVmVeKLAw--.25774S2 X-Coremail-Antispam: 1UD129KBjvdXoWrKF1UurWkJF1UXFyrXrW5Jrb_yoW3Zrc_GF y8tws7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LmIT0mSQAKysyB8BXBdpAt7MWJ3oqqLkA0F+31oU7l8WEG0QYdXdWydd/Am9MgD7WzeQ97FaskNYrJ95E9j8oQCc+tP934z4qCNZVy1losPnj+tyqfMT4zQi5WIJ405nHQtQw6bpH0XcWGLIdh7i+rqr5svJ/0lW8xDXnj+NCTOCnV2QC9Fp8tMhVU+IH9Lg 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: List-Subscribe: List-Unsubscribe: This code calls folio_put() on an error pointer which will lead to a crash. Check for both error pointers and NULL pointers before calling folio_put(). Fixes: 38a55db9877c ("filemap: Handle error return from __filemap_get_folio()") Signed-off-by: Ma Ke --- mm/filemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/filemap.c b/mm/filemap.c index 657bcd887fdb..cd26617d8987 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3420,7 +3420,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 (!IS_ERR(folio)) + if (!IS_ERR_OR_NULL(folio)) folio_put(folio); if (mapping_locked) filemap_invalidate_unlock_shared(mapping);