* Fixed CID 1293: a vnode reference, and the cookie could be leaked.
* Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38195 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2009, Axel Dörfler, [email protected].
|
* Copyright 2002-2010, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||||
@@ -1090,7 +1090,8 @@ devfs_create(fs_volume* _volume, fs_vnode* _dir, const char* name, int openMode,
|
|||||||
struct devfs_vnode* vnode;
|
struct devfs_vnode* vnode;
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
|
|
||||||
TRACE(("devfs_create: dir %p, name \"%s\", openMode 0x%x, fs_cookie %p \n", dir, name, openMode, _cookie));
|
TRACE(("devfs_create: dir %p, name \"%s\", openMode 0x%x, fs_cookie %p \n",
|
||||||
|
dir, name, openMode, _cookie));
|
||||||
|
|
||||||
RecursiveLocker locker(fs->lock);
|
RecursiveLocker locker(fs->lock);
|
||||||
|
|
||||||
@@ -1099,11 +1100,11 @@ devfs_create(fs_volume* _volume, fs_vnode* _dir, const char* name, int openMode,
|
|||||||
if (vnode == NULL)
|
if (vnode == NULL)
|
||||||
return EROFS;
|
return EROFS;
|
||||||
|
|
||||||
if (openMode & O_EXCL)
|
if ((openMode & O_EXCL) != 0)
|
||||||
return B_FILE_EXISTS;
|
return B_FILE_EXISTS;
|
||||||
|
|
||||||
status = get_vnode(fs->volume, vnode->id, NULL);
|
status = get_vnode(fs->volume, vnode->id, NULL);
|
||||||
if (status < B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
locker.Unlock();
|
locker.Unlock();
|
||||||
@@ -1119,18 +1120,18 @@ devfs_create(fs_volume* _volume, fs_vnode* _dir, const char* name, int openMode,
|
|||||||
if (S_ISCHR(vnode->stream.type)) {
|
if (S_ISCHR(vnode->stream.type)) {
|
||||||
BaseDevice* device = vnode->stream.u.dev.device;
|
BaseDevice* device = vnode->stream.u.dev.device;
|
||||||
status = device->InitDevice();
|
status = device->InitDevice();
|
||||||
if (status < B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
goto err2;
|
||||||
|
|
||||||
char path[B_FILE_NAME_LENGTH];
|
char path[B_FILE_NAME_LENGTH];
|
||||||
get_device_name(vnode, path, sizeof(path));
|
get_device_name(vnode, path, sizeof(path));
|
||||||
|
|
||||||
status = device->Open(path, openMode, &cookie->device_cookie);
|
status = device->Open(path, openMode, &cookie->device_cookie);
|
||||||
if (status != B_OK)
|
if (status != B_OK) {
|
||||||
device->UninitDevice();
|
device->UninitDevice();
|
||||||
|
goto err2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (status < B_OK)
|
|
||||||
goto err2;
|
|
||||||
|
|
||||||
*_cookie = cookie;
|
*_cookie = cookie;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user