* Fixed CID 1199-1202: only call the cache listener in case the open succeeded
(this might also have derefenced a potentially freed vnode). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38196 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -5361,13 +5361,15 @@ file_open_entry_ref(dev_t mountID, ino_t directoryID, const char* name,
|
||||
return B_LINK_LIMIT;
|
||||
}
|
||||
|
||||
int fd = open_vnode(vnode, openMode, kernel);
|
||||
if (fd < 0)
|
||||
int newFD = open_vnode(vnode, openMode, kernel);
|
||||
if (newFD >= 0) {
|
||||
// The vnode reference has been transferred to the FD
|
||||
cache_node_opened(vnode, FDTYPE_FILE, vnode->cache, mountID,
|
||||
directoryID, vnode->id, name);
|
||||
} else
|
||||
put_vnode(vnode);
|
||||
|
||||
cache_node_opened(vnode, FDTYPE_FILE, vnode->cache, mountID, directoryID,
|
||||
vnode->id, name);
|
||||
return fd;
|
||||
return newFD;
|
||||
}
|
||||
|
||||
|
||||
@@ -5394,13 +5396,13 @@ file_open(int fd, char* path, int openMode, bool kernel)
|
||||
|
||||
// open the vnode
|
||||
int newFD = open_vnode(vnode, openMode, kernel);
|
||||
// put only on error -- otherwise our reference was transferred to the FD
|
||||
if (newFD < 0)
|
||||
if (newFD >= 0) {
|
||||
// The vnode reference has been transferred to the FD
|
||||
cache_node_opened(vnode, FDTYPE_FILE, vnode->cache,
|
||||
vnode->device, parentID, vnode->id, NULL);
|
||||
} else
|
||||
put_vnode(vnode);
|
||||
|
||||
cache_node_opened(vnode, FDTYPE_FILE, vnode->cache,
|
||||
vnode->device, parentID, vnode->id, NULL);
|
||||
|
||||
return newFD;
|
||||
}
|
||||
|
||||
@@ -5631,13 +5633,15 @@ dir_open_entry_ref(dev_t mountID, ino_t parentID, const char* name, bool kernel)
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
int fd = open_dir_vnode(vnode, kernel);
|
||||
if (fd < 0)
|
||||
int newFD = open_dir_vnode(vnode, kernel);
|
||||
if (newFD >= 0) {
|
||||
// The vnode reference has been transferred to the FD
|
||||
cache_node_opened(vnode, FDTYPE_DIR, vnode->cache, mountID, parentID,
|
||||
vnode->id, name);
|
||||
} else
|
||||
put_vnode(vnode);
|
||||
|
||||
cache_node_opened(vnode, FDTYPE_DIR, vnode->cache, mountID, parentID,
|
||||
vnode->id, name);
|
||||
return fd;
|
||||
return newFD;
|
||||
}
|
||||
|
||||
|
||||
@@ -5657,11 +5661,13 @@ dir_open(int fd, char* path, bool kernel)
|
||||
|
||||
// open the dir
|
||||
int newFD = open_dir_vnode(vnode, kernel);
|
||||
if (newFD < 0)
|
||||
if (newFD >= 0) {
|
||||
// The vnode reference has been transferred to the FD
|
||||
cache_node_opened(vnode, FDTYPE_DIR, vnode->cache, vnode->device,
|
||||
parentID, vnode->id, NULL);
|
||||
} else
|
||||
put_vnode(vnode);
|
||||
|
||||
cache_node_opened(vnode, FDTYPE_DIR, vnode->cache, vnode->device, parentID,
|
||||
vnode->id, NULL);
|
||||
return newFD;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user