Commit dad459e0 authored by Tiezhu Yang's avatar Tiezhu Yang Committed by Greg Kroah-Hartman

staging: rtlwifi: use single_open and single_release properly

single_open() returns -ENOMEM when malloc failed, so the caller function
rtl_debugfs_open_rw() should not always return 0. In addition, when using
single_open(), we should use single_release() instead of seq_release() in
the file_operations structure to avoid a memory leak.
Signed-off-by: default avatarTiezhu Yang <kernelpatch@126.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bb1192cb
...@@ -95,7 +95,7 @@ static const struct file_operations file_ops_common = { ...@@ -95,7 +95,7 @@ static const struct file_operations file_ops_common = {
.open = dl_debug_open_common, .open = dl_debug_open_common,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
.release = seq_release, .release = single_release,
}; };
static int rtl_debug_get_mac_page(struct seq_file *m, void *v) static int rtl_debug_get_mac_page(struct seq_file *m, void *v)
...@@ -485,18 +485,20 @@ static int rtl_debug_get_phydm_cmd(struct seq_file *m, void *v) ...@@ -485,18 +485,20 @@ static int rtl_debug_get_phydm_cmd(struct seq_file *m, void *v)
static int rtl_debugfs_open_rw(struct inode *inode, struct file *filp) static int rtl_debugfs_open_rw(struct inode *inode, struct file *filp)
{ {
int ret = 0;
if (filp->f_mode & FMODE_READ) if (filp->f_mode & FMODE_READ)
single_open(filp, rtl_debug_get_common, inode->i_private); ret = single_open(filp, rtl_debug_get_common, inode->i_private);
else else
filp->private_data = inode->i_private; filp->private_data = inode->i_private;
return 0; return ret;
} }
static int rtl_debugfs_close_rw(struct inode *inode, struct file *filp) static int rtl_debugfs_close_rw(struct inode *inode, struct file *filp)
{ {
if (filp->f_mode == FMODE_READ) if (filp->f_mode == FMODE_READ)
seq_release(inode, filp); single_release(inode, filp);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment