From nobody Mon May 25 03:04:49 2026 Received: from cvsmtppost101.wmail.worksmobile.com (cvsmtppost101.wmail.worksmobile.com [125.209.209.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D670C3E834A for ; Tue, 19 May 2026 08:51:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=125.209.209.40 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779180713; cv=none; b=L0eGopFywIQtCJmXNocFZHJG8Wd798oTiUCmyTkUGayI04KfDUHQqCWLItKMz592SlrPJMPtAhxIpjAJzlgOeodoMIxlysHHVSmVQBshTVIixLpSnNb2fGmcK/9yWBoIWic2ZhNsdqGTNFn1bTu9Z4NdPGTGKjNH8SCSyo8LNk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779180713; c=relaxed/simple; bh=m72EeEErYn8IjUAQQtRajGQn/TcdgEZ3GhbKW3Zvzms=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tycNif4V3W5Q1v4wrI12jkwpkWTV860hy/9i/8IJNsa7V5xXyXdOf/lpLsjjEpecTnxC9hQWr5SgsbhNJVrlsGnN5D0C6hb3DRZD7BSPane2J/FxGswVwUczn03IZLmtEWT6wZGowY+Dms6FDgzmPFMQ/aPMgsjHL1heqzpYBqk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=korea.ac.kr; spf=pass smtp.mailfrom=korea.ac.kr; dkim=pass (2048-bit key) header.d=worksmobile.com header.i=@worksmobile.com header.b=ceD9mfUx; dkim=pass (1024-bit key) header.d=korea.ac.kr header.i=@korea.ac.kr header.b=GKbZBzh9; arc=none smtp.client-ip=125.209.209.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=korea.ac.kr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=korea.ac.kr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=worksmobile.com header.i=@worksmobile.com header.b="ceD9mfUx"; dkim=pass (1024-bit key) header.d=korea.ac.kr header.i=@korea.ac.kr header.b="GKbZBzh9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=worksmobile.com; s=s20171120; t=1779180700; bh=m72EeEErYn8IjUAQQtRajGQn/TcdgEZ3GhbKW3Zvzms=; h=From:To:Subject:Date:Message-Id:From:Subject:Feedback-ID: X-Works-Security; b=ceD9mfUxw6mqEkNnclsSpQauMT/kZYjPfwXpUZjyMminexHKXKZeUylI8BHevrxA+ Tv+jrozh29pHVIUO9hd/vEn4CdrH9Qj3nPdjzbBNpHiDWNJKwlpCnhIDRG7OZRiQds Y17wSHB+M1pj/ozjHlqAt5oqXul2XtB1ql9Vkqk8lnas8l+EWXE9CowpKCwhEgN7Ip /aFxbnoAYDWefH6lMLqIkuWglvU+ShQlDSAZgHXZh02N5DVyoFYD4uWMA31ZZ0Stl9 dMymdjD04C4hZBRBn+kE3KadIo77KKpxcmRxT0KajGM/BdblbFQbdHty058t4E5aZc hlN5oVJ2nz5iA== Received: from cvsendbo005.wmail ([10.112.11.110]) by cvsmtppost101.wmail.worksmobile.com with ESMTP id R+42023HSO6-eGNgQwVD+w for ; Tue, 19 May 2026 08:51:40 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=korea.ac.kr; s=naverworks; t=1779180700; bh=m72EeEErYn8IjUAQQtRajGQn/TcdgEZ3GhbKW3Zvzms=; h=From:To:Subject:Date:Message-Id:From:Subject:Feedback-ID: X-Works-Security; b=GKbZBzh9NO9+sKz9KGwIRACzPENgANC+FANI5M+mu1oqvZYTNXsHWj5pf1F4opnVU i7cXPvmi89gkkUHB9CK8qQ5013wus66lc/D4y1sYvfLUZjxOURdB/aXILrrO9iNL0o mwA14Yc+5SdZJUGPPqCuLokTnz/We9G+UNGsBHIY= X-Session-ID: Yuaa0-W0Sj2Jsd4s6z3u9Q X-Works-Send-Opt: EendjAIYjHm/FqM9FqJYFxMqFNwYjAg= X-Works-Smtp-Source: ewYdKxvXFqJZ+HmmKAK/+6E= Received: from s2lab05.. ([163.152.163.130]) by jvnsmtp403.gwmail.worksmobile.com with ESMTP id Yuaa0-W0Sj2Jsd4s6z3u9Q for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 19 May 2026 08:51:40 -0000 From: Ingyu Jang To: Christian Brauner , Jan Kara Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] ufs: Defensively handle NULL return from ufs_get_locked_folio() Date: Tue, 19 May 2026 17:51:38 +0900 Message-Id: <20260519085138.55591-1-ingyujang25@korea.ac.kr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260514193256.2556905-1-ingyujang25@korea.ac.kr> References: <20260514193256.2556905-1-ingyujang25@korea.ac.kr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ufs_get_locked_folio() may return either an error pointer (when read_mapping_folio() fails) or NULL (when a concurrent truncate has detached the folio from its mapping). In ufs_alloc_lastblock() the NULL path cannot be reached in practice because the only caller, ufs_truncate(), holds i_rwsem and so serialises against other truncates. Still, the current IS_ERR()-only check does not match the documented contract of ufs_get_locked_folio() and is fragile against future callers. Use IS_ERR_OR_NULL() to match the helper's return contract. Signed-off-by: Ingyu Jang Reviewed-by: Jan Kara --- Changes in v2: - Rewrote changelog per Jan Kara's review feedback to clarify that the NULL path is unreachable in practice (i_rwsem in ufs_truncate()), and framed the change as matching the helper's return contract / future- proofing rather than fixing an active race. - Diff unchanged. Link to v1: https://lore.kernel.org/all/20260514193256.2556905-1-ingyujang2= 5@korea.ac.kr/ fs/ufs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 440d014cc5ed5..989ff3d3ad179 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c @@ -1051,7 +1051,7 @@ static int ufs_alloc_lastblock(struct inode *inode, l= off_t size) =20 folio =3D ufs_get_locked_folio(mapping, lastfrag >> (PAGE_SHIFT - inode->i_blkbits)); - if (IS_ERR(folio)) { + if (IS_ERR_OR_NULL(folio)) { err =3D -EIO; goto out; } --=20 2.34.1