Skip to content

Commit e98d519

Browse files
committed
Fix incorrect open count check in release function
In the original code, the kernel module stops producing new boards when atomic_dec_and_test(&open_cnt) returns zero, but it will return zero when the resulting value of open_cnt is nonzero. Therefore, in the origional code, if we kill the user program who is interacting with this kernel module, it won't stop producing new boards, but it is supposed to stop producing new boards when open_cnt becomes zero. As a result, the code is modified so that it stops producing new boards when atomic_dec_and_test(&open_cnt) returns one.
1 parent 19ec2e5 commit e98d519

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ static int kxo_open(struct inode *inode, struct file *filp)
428428
static int kxo_release(struct inode *inode, struct file *filp)
429429
{
430430
pr_debug("kxo: %s\n", __func__);
431-
if (atomic_dec_and_test(&open_cnt) == 0) {
431+
if (atomic_dec_and_test(&open_cnt)) {
432432
del_timer_sync(&timer);
433433
flush_workqueue(kxo_workqueue);
434434
fast_buf_clear();

0 commit comments

Comments
 (0)