From patchwork Tue Nov 14 15:31:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenchao Hao X-Patchwork-Id: 743808 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 AB8AE41755 for ; Tue, 14 Nov 2023 15:31:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none 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 Precedence: bulk X-Mailing-List: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 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: Xiubo Li Reviewed-by: Luis Henriques --- 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 *fsc, struct kstatfs *buf) realm = 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; spin_lock(&realm->inodes_with_caps_lock);