add: result = B_ERROR;
context: static status_t open_hook (const char* name, uint32 flags, void** cookie) {	int32 index = 0;	device_info *di;	shared_info *si;	thread_id	thid;	thread_info	thinfo;	status_t	result = B_OK;	vuint32		*regs, *regs2;	char shared_name[B_OS_NAME_LENGTH];	/* find the device name in the list of devices */	/* we're never passed a name we didn't publish */	while (pd->device_names[index] && (strcmp(name, pd->device_names[index]) != 0)) index++;	/* for convienience */	di = &(pd->di[index]);	/* make sure no one else has write access to the common data */	AQUIRE_BEN(pd->kernel);	/* if it's already open for writing */	if (di->is_open) {		/* mark it open another time */		goto mark_as_open;	}	/* create the shared area */	sprintf(shared_name, DEVICE_FORMAT " shared",		di->pcii.vendor_id, di->pcii.device_id,		di->pcii.bus, di->pcii.device, di->pcii.function);	/* create this area with NO user-space read or write permissions, to prevent accidental dammage */	di->shared_area = create_area(shared_name, (void **)&(di->si), B_ANY_KERNEL_ADDRESS, ((sizeof(shared_info) + (B_PAGE_SIZE - 1)) & ~(B_PAGE_SIZE - 1)), B_FULL_LOCK, 0);	if (di->shared_area < 0) {		/* return the error */		result = di->shared_area;		goto done;	}	/* save a few dereferences */	si = di->si;	/* save the vendor and device IDs */	si->vendor_id = di->pcii.vendor_id;	si->device_id = di->pcii.device_id;	si->revision = di->pcii.revision;	/* map the device */	result = map_device(di);	if (result < 0) goto free_shared;	result = B_OK;	/* create a semaphore for vertical blank management */	si->vblank = create_sem(0, di->name);	if (si->vblank < 0) {		result = si->vblank;		goto unmap;	}	/* change the owner of the semaphores to the opener's team */	/* this is required because apps can't aquire kernel semaphores */	thid = find_thread(NULL);	get_thread_info(thid, &thinfo);	set_sem_owner(si->vblank, thinfo.team);	/* assign local regs pointer for SAMPLExx() macros */	regs = di->regs;	regs2 = di->regs2;	/* disable and clear any pending interrupts */	disable_vbi(regs, regs2);	/* If there is a valid interrupt line assigned then set up interrupts */	if ((di->pcii.u.h0.interrupt_pin == 0x00) ||	    (di->pcii.u.h0.interrupt_line == 0xff) || /* no IRQ assigned */	    (di->pcii.u.h0.interrupt_line <= 0x02))   /* system IRQ assigned */	{		/* interrupt does not exist so exit without installing our handler */		goto delete_the_sem;	}	else	{		/* otherwise install our interrupt handler */		result = install_io_interrupt_handler(di->pcii.u.h0.interrupt_line, mn_interrupt, (void *)di, 0);		/* bail if we couldn't install the handler */		if (result != B_OK) goto delete_the_sem;	}mark_as_open:	/* mark the device open */	di->is_open++;	/* send the cookie to the opener */	*cookie = di;		goto done;delete_the_sem:	delete_sem(si->vblank);unmap:	unmap_device(di);free_shared:	/* clean up our shared area */	delete_area(di->shared_area);	di->shared_area = -1;	di->si = NULL;done:	/* end of critical section */	RELEASE_BEN(pd->kernel);	/* all done, return the status */	return result;}