From: Markus Elfring <Markus.Elfring@web.de>
To: ceph-devel@vger.kernel.org, Alex Markuze <amarkuze@redhat.com>,
Helge Deller <deller@gmx.de>, Ilya Dryomov <idryomov@gmail.com>,
Kees Cook <kees@kernel.org>,
Viacheslav Dubeyko <slava@dubeyko.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] ceph: Move a variable assignment behind a condition check in __ceph_remove_cap()
Date: Mon, 13 Jul 2026 13:35:01 +0200 [thread overview]
Message-ID: <5010d7d4-e321-4999-aca6-1caa040f3037@web.de> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 13 Jul 2026 13:21:29 +0200
The address of a data structure member was determined before
a corresponding null pointer check in the implementation of
the function “__ceph_remove_cap”.
Thus avoid the risk for undefined behaviour by moving the assignment
for the variable “inode” behind a condition check.
This issue was detected by using the Coccinelle software.
Fixes: 38d46409c4639a1d659ebfa70e27a8bed6b8ee1d ("ceph: print cluster fsid and client global_id in all debug logs")
Cc: stable@vger.kernel.org
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
fs/ceph/caps.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 4b37d9ffdf7f..5b6640707949 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -1124,7 +1124,7 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release)
struct ceph_mds_session *session = cap->session;
struct ceph_client *cl = session->s_mdsc->fsc->client;
struct ceph_inode_info *ci = cap->ci;
- struct inode *inode = &ci->netfs.inode;
+ struct inode *inode;
struct ceph_mds_client *mdsc;
int removed = 0;
@@ -1135,7 +1135,7 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release)
}
lockdep_assert_held(&ci->i_ceph_lock);
-
+ inode = &ci->netfs.inode;
doutc(cl, "%p from %p %llx.%llx\n", cap, inode, ceph_vinop(inode));
mdsc = ceph_inode_to_fs_client(&ci->netfs.inode)->mdsc;
--
2.55.0
next reply other threads:[~2026-07-13 11:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 11:35 Markus Elfring [this message]
2026-07-13 22:10 ` Viacheslav Dubeyko
2026-07-14 7:19 ` Dan Carpenter
2026-07-14 7:33 ` Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5010d7d4-e321-4999-aca6-1caa040f3037@web.de \
--to=markus.elfring@web.de \
--cc=amarkuze@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=deller@gmx.de \
--cc=idryomov@gmail.com \
--cc=kees@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=slava@dubeyko.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox