From patchwork Wed Mar 2 08:54:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 547609 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 F33A5C433F5 for ; Wed, 2 Mar 2022 08:54:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240255AbiCBIzL (ORCPT ); Wed, 2 Mar 2022 03:55:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240259AbiCBIzK (ORCPT ); Wed, 2 Mar 2022 03:55:10 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5343B5FF2D for ; Wed, 2 Mar 2022 00:54:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646211266; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WcjgSGGQqZabXZBVqDRGvtr5s3kqrhUmGA1CTEaqEoQ=; b=JcwDGSgo4VnzAI1oJD2ITn9k0FPe1N8F6hvmBD12EGDjUiT+NIFR6IpXxnS7pvUg80LcqZ RI/F044JNz9AQIC0iD4ZEoG4ZST62K5SVMidQcTozCsIHVhBxVfKcOmKOpwnko8vVwwJIU vwjdqa/Go5I/gKMSGbkMmIMLteW8pkg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-45-RQpGkEytOr2w6OqxZlh_DA-1; Wed, 02 Mar 2022 03:54:23 -0500 X-MC-Unique: RQpGkEytOr2w6OqxZlh_DA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 325E51091DA1; Wed, 2 Mar 2022 08:54:22 +0000 (UTC) Received: from lxbceph1.gsslab.pek2.redhat.com (unknown [10.72.47.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BD71646D0; Wed, 2 Mar 2022 08:54:20 +0000 (UTC) From: xiubli@redhat.com To: jlayton@kernel.org Cc: idryomov@gmail.com, vshankar@redhat.com, ceph-devel@vger.kernel.org, Xiubo Li Subject: [PATCH 2/2] ceph: fix a NULL pointer dereference in ceph_handle_caps() Date: Wed, 2 Mar 2022 16:54:02 +0800 Message-Id: <20220302085402.64740-3-xiubli@redhat.com> In-Reply-To: <20220302085402.64740-1-xiubli@redhat.com> References: <20220302085402.64740-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Xiubo Li The ceph_find_inode() may will fail and return NULL. Signed-off-by: Xiubo Li --- fs/ceph/caps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 0b36020207fd..0762b55fdbcb 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -4303,7 +4303,6 @@ void ceph_handle_caps(struct ceph_mds_session *session, /* lookup ino */ inode = ceph_find_inode(mdsc->fsc->sb, vino); - ci = ceph_inode(inode); dout(" op %s ino %llx.%llx inode %p\n", ceph_cap_op_name(op), vino.ino, vino.snap, inode); @@ -4333,6 +4332,7 @@ void ceph_handle_caps(struct ceph_mds_session *session, } goto flush_cap_releases; } + ci = ceph_inode(inode); /* these will work even if we don't have a cap yet */ switch (op) {