diff options
author | Tiezhu Yang <kernelpatch@126.com> | 2018-05-26 10:46:22 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-05-31 13:00:53 -0400 |
commit | dad459e052dc73493a4058b0f05f7e210691a0ba (patch) | |
tree | 92cf3139971b9507928df9e90cbbe423955ac84b | |
parent | bb1192cbf43ec5b0db9ed593fa150cba917642ae (diff) |
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: Tiezhu Yang <kernelpatch@126.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/rtlwifi/debug.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/staging/rtlwifi/debug.c b/drivers/staging/rtlwifi/debug.c index c041bc315616..bf360f855c12 100644 --- a/drivers/staging/rtlwifi/debug.c +++ b/drivers/staging/rtlwifi/debug.c | |||
@@ -95,7 +95,7 @@ static const struct file_operations file_ops_common = { | |||
95 | .open = dl_debug_open_common, | 95 | .open = dl_debug_open_common, |
96 | .read = seq_read, | 96 | .read = seq_read, |
97 | .llseek = seq_lseek, | 97 | .llseek = seq_lseek, |
98 | .release = seq_release, | 98 | .release = single_release, |
99 | }; | 99 | }; |
100 | 100 | ||
101 | static int rtl_debug_get_mac_page(struct seq_file *m, void *v) | 101 | 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 | 485 | ||
486 | static int rtl_debugfs_open_rw(struct inode *inode, struct file *filp) | 486 | static int rtl_debugfs_open_rw(struct inode *inode, struct file *filp) |
487 | { | 487 | { |
488 | int ret = 0; | ||
489 | |||
488 | if (filp->f_mode & FMODE_READ) | 490 | if (filp->f_mode & FMODE_READ) |
489 | single_open(filp, rtl_debug_get_common, inode->i_private); | 491 | ret = single_open(filp, rtl_debug_get_common, inode->i_private); |
490 | else | 492 | else |
491 | filp->private_data = inode->i_private; | 493 | filp->private_data = inode->i_private; |
492 | 494 | ||
493 | return 0; | 495 | return ret; |
494 | } | 496 | } |
495 | 497 | ||
496 | static int rtl_debugfs_close_rw(struct inode *inode, struct file *filp) | 498 | static int rtl_debugfs_close_rw(struct inode *inode, struct file *filp) |
497 | { | 499 | { |
498 | if (filp->f_mode == FMODE_READ) | 500 | if (filp->f_mode == FMODE_READ) |
499 | seq_release(inode, filp); | 501 | single_release(inode, filp); |
500 | 502 | ||
501 | return 0; | 503 | return 0; |
502 | } | 504 | } |