From 7c340b1cc994446e7fd148d84fc60ea3c564cbf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Thu, 30 Jun 2022 11:37:11 +0200 Subject: [PATCH] pc/wifi: implement iput dummy The 'iput()' function is called from '__sock_release()' when the sock object has no valid file object. The release function on the other hand is called when the supplicant closes a socket. Fixes #xxx. --- repos/pc/src/lib/wifi/generated_dummies.c | 8 ------- repos/pc/src/lib/wifi/lx_emul.c | 26 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/repos/pc/src/lib/wifi/generated_dummies.c b/repos/pc/src/lib/wifi/generated_dummies.c index ae11f79aed..169d98ec4a 100644 --- a/repos/pc/src/lib/wifi/generated_dummies.c +++ b/repos/pc/src/lib/wifi/generated_dummies.c @@ -562,14 +562,6 @@ void iov_iter_revert(struct iov_iter * i,size_t unroll) } -#include - -void iput(struct inode * inode) -{ - lx_emul_trace_and_stop(__func__); -} - - #include void irq_work_tick(void) diff --git a/repos/pc/src/lib/wifi/lx_emul.c b/repos/pc/src/lib/wifi/lx_emul.c index 393234e264..92aa7c210a 100644 --- a/repos/pc/src/lib/wifi/lx_emul.c +++ b/repos/pc/src/lib/wifi/lx_emul.c @@ -118,20 +118,36 @@ struct vfsmount * kern_mount(struct file_system_type * type) struct inode * new_inode_pseudo(struct super_block * sb) { - const struct super_operations *ops = sb->s_op; - struct inode *inode; + const struct super_operations *ops = sb->s_op; + struct inode *inode; - if (ops->alloc_inode) { - inode = ops->alloc_inode(sb); - } + if (ops->alloc_inode) + inode = ops->alloc_inode(sb); if (!inode) return (struct inode*)ERR_PTR(-ENOMEM); + if (!inode->free_inode) + inode->free_inode = ops->free_inode; + return inode; } +void iput(struct inode * inode) +{ + if (!inode) + return; + + if (atomic_read(&inode->i_count) + && !atomic_dec_and_test(&inode->i_count)) + return; + + if (inode->free_inode) + inode->free_inode(inode); +} + + #include #if 0