Skip to content

Commit 5b697f8

Browse files
committed
Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs fix from Al Viro: "Fixes an obvious bug (memory leak introduced in 5.8)" * 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: pipe: Fix memory leaks in create_pipe_files()
2 parents c120ec1 + 8a018eb commit 5b697f8

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

fs/pipe.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -894,19 +894,18 @@ int create_pipe_files(struct file **res, int flags)
894894
{
895895
struct inode *inode = get_pipe_inode();
896896
struct file *f;
897+
int error;
897898

898899
if (!inode)
899900
return -ENFILE;
900901

901902
if (flags & O_NOTIFICATION_PIPE) {
902-
#ifdef CONFIG_WATCH_QUEUE
903-
if (watch_queue_init(inode->i_pipe) < 0) {
903+
error = watch_queue_init(inode->i_pipe);
904+
if (error) {
905+
free_pipe_info(inode->i_pipe);
904906
iput(inode);
905-
return -ENOMEM;
907+
return error;
906908
}
907-
#else
908-
return -ENOPKG;
909-
#endif
910909
}
911910

912911
f = alloc_file_pseudo(inode, pipe_mnt, "",

include/linux/watch_queue.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ static inline void remove_watch_list(struct watch_list *wlist, u64 id)
122122
*/
123123
#define watch_sizeof(STRUCT) (sizeof(STRUCT) << WATCH_INFO_LENGTH__SHIFT)
124124

125+
#else
126+
static inline int watch_queue_init(struct pipe_inode_info *pipe)
127+
{
128+
return -ENOPKG;
129+
}
130+
125131
#endif
126132

127133
#endif /* _LINUX_WATCH_QUEUE_H */

0 commit comments

Comments
 (0)