From ece4348807190870be5e484f5edbd1adfc6c1f5b Mon Sep 17 00:00:00 2001 From: Sam Lang Date: Sat, 23 Mar 2013 14:07:59 -0500 Subject: [PATCH] client: don't set other if lookup fails in rename On rename, only set the other inode if the lookup for the destination succeeds, otherwise we hit a segv in set_other_inode(). Fixes #4517. Signed-off-by: Sam Lang Tested-by: Noah Watkins --- src/client/Client.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 792d4a2fdda70..d1f8564aa8f6e 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -7340,10 +7340,12 @@ int Client::_rename(Inode *fromdir, const char *fromname, Inode *todir, const ch Inode *otherin; res = _lookup(todir, toname, &otherin); - if (res != 0 && res != -ENOENT) + if (res != 0 && res != -ENOENT) { goto fail; - req->set_other_inode(otherin); - req->other_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL; + } else if (res == 0) { + req->set_other_inode(otherin); + req->other_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL; + } req->set_inode(todir); -- 2.39.5