Skip to content

Commit 989e994

Browse files
authored
Merge pull request #317 from wurrrrrrrrrr/master
Improve example in 15.2 Work queues with error handling and cleanup
2 parents f105003 + b30af6b commit 989e994

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

examples/sched.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ static void work_handler(struct work_struct *data)
1616
static int __init sched_init(void)
1717
{
1818
queue = alloc_workqueue("HELLOWORLD", WQ_UNBOUND, 1);
19+
if (!queue) {
20+
pr_err("Failed to allocate workqueue\n");
21+
return -ENOMEM;
22+
}
1923
INIT_WORK(&work, work_handler);
2024
queue_work(queue, &work);
2125
return 0;
2226
}
2327

2428
static void __exit sched_exit(void)
2529
{
30+
flush_workqueue(queue);
2631
destroy_workqueue(queue);
2732
}
2833

0 commit comments

Comments
 (0)