From 59cffbabcffa2c55acf43eb604d42c7a24d405c3 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Fri, 31 May 2013 18:49:30 +0200 Subject: [PATCH] mds/Locker.cc: fix dereference after null check CID 716919 (#1 of 1): Dereference after null check (FORWARD_NULL) var_deref_model: Passing null pointer "cap" to function "Capability::inc_suppress()", which dereferences it. Check for 'cap' before use it as in other places of the function. Signed-off-by: Danny Al-Gaaf --- src/mds/Locker.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 41421f3e2a6d8..74a766256b4d8 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -2794,7 +2794,8 @@ bool Locker::_do_cap_update(CInode *in, Capability *cap, dout(10) << " i want to change file_max, but lock won't allow it (yet)" << dendl; if (in->filelock.is_stable()) { bool need_issue = false; - cap->inc_suppress(); + if (cap) + cap->inc_suppress(); if (in->mds_caps_wanted.empty() && (in->get_loner() >= 0 || (in->get_wanted_loner() >= 0 && in->try_set_loner()))) { if (in->filelock.get_state() != LOCK_EXCL) @@ -2803,7 +2804,8 @@ bool Locker::_do_cap_update(CInode *in, Capability *cap, simple_lock(&in->filelock, &need_issue); if (need_issue) issue_caps(in); - cap->dec_suppress(); + if (cap) + cap->dec_suppress(); } if (!in->filelock.can_wrlock(client) && !in->filelock.can_force_wrlock(client)) { -- 2.39.5