From nobody Tue Dec 30 14:58:35 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEBB1C4167D for ; Tue, 14 Nov 2023 15:31:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233656AbjKNPbz (ORCPT ); Tue, 14 Nov 2023 10:31:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232277AbjKNPbx (ORCPT ); Tue, 14 Nov 2023 10:31:53 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA6C4124; Tue, 14 Nov 2023 07:31:49 -0800 (PST) Received: from kwepemm000012.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SV9J40s8RzvQd3; Tue, 14 Nov 2023 23:31:32 +0800 (CST) Received: from build.huawei.com (10.175.101.6) by kwepemm000012.china.huawei.com (7.193.23.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 14 Nov 2023 23:31:47 +0800 From: Wenchao Hao To: Xiubo Li , Ilya Dryomov , Jeff Layton , , CC: , Wenchao Hao Subject: [PATCH] ceph: quota: Fix invalid pointer access in Date: Tue, 14 Nov 2023 23:31:08 +0800 Message-ID: <20231114153108.1932884-1-haowenchao2@huawei.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm000012.china.huawei.com (7.193.23.142) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This issue is reported by smatch, get_quota_realm() might return ERR_PTR, so we should using IS_ERR_OR_NULL here to check the return value. Signed-off-by: Wenchao Hao Reviewed-by: Luis Henriques Reviewed-by: Xiubo Li --- fs/ceph/quota.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/quota.c b/fs/ceph/quota.c index 9d36c3532de1..c4b2929c6a83 100644 --- a/fs/ceph/quota.c +++ b/fs/ceph/quota.c @@ -495,7 +495,7 @@ bool ceph_quota_update_statfs(struct ceph_fs_client *fs= c, struct kstatfs *buf) realm =3D get_quota_realm(mdsc, d_inode(fsc->sb->s_root), QUOTA_GET_MAX_BYTES, true); up_read(&mdsc->snap_rwsem); - if (!realm) + if (IS_ERR_OR_NULL(realm)) return false; =20 spin_lock(&realm->inodes_with_caps_lock); --=20 2.32.0