]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds/Locker.cc: fix dereference after null check
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 31 May 2013 16:49:30 +0000 (18:49 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 31 May 2013 17:15:22 +0000 (19:15 +0200)
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 <danny.al-gaaf@bisect.de>
src/mds/Locker.cc

index 41421f3e2a6d8f7f13668685437515a397275b04..74a766256b4d89dae52948f68b99e8ce02e4294f 100644 (file)
@@ -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)) {