From 3568352d8df3785c56c2fde26f26b385ac2cc1c5 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 6 Apr 2008 12:07:45 +0000 Subject: [PATCH] When a partition was unpublished from devfs the devfs_delete_vnode() would also free the device info which it must not do, as this info is in fact just a pointer to the device info of the raw node. Removing a raw device that had partitions published therefore always lead into KDL when closing the raw device after unpublising the partition, as the close_hook pointer which sits in the device info now was 0xdeadbeef. This should make for example unplugging USB devices work as expected. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24827 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/fs/devfs.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/system/kernel/fs/devfs.cpp b/src/system/kernel/fs/devfs.cpp index 5242b5f5e5..dad71351e9 100644 --- a/src/system/kernel/fs/devfs.cpp +++ b/src/system/kernel/fs/devfs.cpp @@ -824,16 +824,19 @@ devfs_delete_vnode(struct devfs *fs, struct devfs_vnode *vnode, hash_remove(fs->vnode_hash, vnode); if (S_ISCHR(vnode->stream.type)) { - // for partitions, we have to release the raw device + // for partitions, we have to release the raw device but must + // not free the device info as it was inherited from the raw + // device and is still in use there if (vnode->stream.u.dev.partition) { put_vnode(fs->volume, vnode->stream.u.dev.partition->raw_device->id); - } else + } else { delete vnode->stream.u.dev.scheduler; - // remove API conversion from old to new drivers - if (vnode->stream.u.dev.node == NULL) - free(vnode->stream.u.dev.info); + // remove API conversion from old to new drivers + if (vnode->stream.u.dev.node == NULL) + free(vnode->stream.u.dev.info); + } } free(vnode->name);