Skip to content

Commit 412fb94

Browse files
committed
labs: interrupts: Fix release of DATA_REG
In the touched code we are trying to request two regions. But in the case when the first request would succeed and the second one fail, we would not correctly free the first region on the error path. This commit fixes that by introducing an additional label and changing a goto destination.
1 parent f1eec70 commit 412fb94

File tree

1 file changed

+3
-2
lines changed
  • tools/labs/templates/interrupts

1 file changed

+3
-2
lines changed

tools/labs/templates/interrupts/kbd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static int kbd_init(void)
223223
}
224224
if (request_region(I8042_STATUS_REG+1, 1, MODULE_NAME) == NULL) {
225225
err = -EBUSY;
226-
goto out_unregister;
226+
goto out_release_region;
227227
}
228228

229229
/* TODO 3: initialize spinlock */
@@ -244,9 +244,10 @@ static int kbd_init(void)
244244
pr_notice("Driver %s loaded\n", MODULE_NAME);
245245
return 0;
246246

247-
/*TODO 2/3: release regions in case of error */
247+
/*TODO 2/4: release regions in case of error */
248248
out_release_regions:
249249
release_region(I8042_STATUS_REG+1, 1);
250+
out_release_region:
250251
release_region(I8042_DATA_REG+1, 1);
251252

252253
out_unregister:

0 commit comments

Comments
 (0)