如果你看seq_release:
int seq_release(struct inode *inode, struct file *file)
{
struct seq_file *m = file->private_data;
kvfree(m->buf);
kfree(m);
return 0;
}
它有效地做了kfree(file-> private_data)
现在,file-> private_data在mounts_open_common中设置为
file->private_data = &p->m;
这就是你问题中的kmalloc.
m成员不是指针,因此不应该允许释放.但是,它是struct proc_mounts的1.成员
struct proc_mounts {
struct seq_file m;
struct mnt_namespace *ns;
struct path root;
int (*show)(struct seq_file *, struct vfsmount *);
void *cached_mount;
u64 cached_event;
loff_t cached_index;
};
所以seq_release()对m成员的地址执行kfree(),这与使用p = kmalloc(sizeof(struct proc_mounts),GFP_KERNEL)获得的地址相同;
我想这对静态分析仪来说不是很友好.但是没有内存泄漏.