From 87784cafb89306b7e11440470a23302c14469c28 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Mon, 27 Jan 2014 21:04:13 +0000 Subject: [PATCH] vesa: Fix tracking of device opens / closes * Don't raise the open_count when the open fails --- src/add-ons/kernel/drivers/graphics/vesa/device.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/add-ons/kernel/drivers/graphics/vesa/device.cpp b/src/add-ons/kernel/drivers/graphics/vesa/device.cpp index 144e4936ed..0ea3602341 100644 --- a/src/add-ons/kernel/drivers/graphics/vesa/device.cpp +++ b/src/add-ons/kernel/drivers/graphics/vesa/device.cpp @@ -51,13 +51,12 @@ device_open(const char* name, uint32 flags, void** _cookie) return B_BAD_VALUE; vesa_info* info = gDeviceInfo[id]; - *_cookie = info; mutex_lock(&gLock); status_t status = B_OK; - if (info->open_count++ == 0) { + if (info->open_count == 0) { // this device has been opened for the first time, so // we allocate needed resources and initialize the structure if (status == B_OK) @@ -66,6 +65,11 @@ device_open(const char* name, uint32 flags, void** _cookie) info->id = id; } + if (status == B_OK) { + info->open_count++; + *_cookie = info; + } + mutex_unlock(&gLock); return status; }